⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 borrow.java

📁 使用开源项目OfBiz工作流引擎进行二次开发的一个例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.jat.test;import java.net.*;import java.sql.*;import java.text.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;import javax.mail.*;import javax.mail.internet.*;import org.ofbiz.core.entity.*;import org.ofbiz.core.service.*;import org.ofbiz.core.service.job.*;import org.ofbiz.core.stats.*;import org.ofbiz.core.util.*;import org.ofbiz.core.workflow.*;import org.ofbiz.core.security.*;import org.ofbiz.commonapp.order.order.*;import org.ofbiz.commonapp.party.contact.*;import org.ofbiz.commonapp.product.catalog.*;import org.ofbiz.commonapp.marketing.tracking.*;import org.ofbiz.core.workflow.definition.*;import org.ofbiz.core.workflow.client.*;public class Borrow{	public static final String module = Borrow.class.getName();		public static String dman(HttpServletRequest request, HttpServletResponse response)	{		try		{			GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");			LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");						String workEffortId=request.getParameter("workEffortId");			String borrowId=request.getParameter("borrowId");			String dman=request.getParameter("dman");			if(dman==null)			{				dman="";			}			String roleTypeId=request.getParameter("roleTypeId");			String fromDateS=request.getParameter("fromDate");			int year=Integer.parseInt(fromDateS.substring(0,4))-1900;			int month=Integer.parseInt(fromDateS.substring(5,7))-1;			int day=Integer.parseInt(fromDateS.substring(8,10));			int hour=Integer.parseInt(fromDateS.substring(11,13));			int minute=Integer.parseInt(fromDateS.substring(14,16));			int second=Integer.parseInt(fromDateS.substring(17,19));			Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);						//保存意见			GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));			borrow.set("dman",dman);			borrow.store();						//完成activity			Security security = dispatcher.getSecurity();			GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);			String partyId = (String)userLogin.getString("partyId");						if (!hasPermission(security, workEffortId, userLogin))			{				Debug.log("没有权限完成当前任务!");				return "error";			}						try			{				Map actResults = new HashMap();				WorkflowClient client=new WorkflowClient(delegator,dispatcher);				client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);			}			catch(WfException we)			{				Debug.log(we);				return "error";			}						return "success";		}		catch(Exception e)		{			Debug.log(e);			return "error";		}	}		public static String gman(HttpServletRequest request, HttpServletResponse response)	{		try		{			GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");			LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");						String workEffortId=request.getParameter("workEffortId");			String borrowId=request.getParameter("borrowId");			String gman=request.getParameter("gman");			if(gman==null)			{				gman="";			}			String roleTypeId=request.getParameter("roleTypeId");			String fromDateS=request.getParameter("fromDate");			int year=Integer.parseInt(fromDateS.substring(0,4))-1900;			int month=Integer.parseInt(fromDateS.substring(5,7))-1;			int day=Integer.parseInt(fromDateS.substring(8,10));			int hour=Integer.parseInt(fromDateS.substring(11,13));			int minute=Integer.parseInt(fromDateS.substring(14,16));			int second=Integer.parseInt(fromDateS.substring(17,19));			Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);						//保存意见			GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));			borrow.set("gman",gman);			borrow.store();						//完成activity			Security security = dispatcher.getSecurity();			GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);			String partyId = (String)userLogin.getString("partyId");			if (!hasPermission(security, workEffortId, userLogin))			{				Debug.log("没有权限完成当前任务!");				return "error";			}			try			{				Map actResults = new HashMap();				WorkflowClient client=new WorkflowClient(delegator,dispatcher);				client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);			}			catch(WfException we)			{				Debug.log(we);				return "error";			}						return "success";		}		catch(Exception e)		{			Debug.log(e);			return "error";		}	}		public static String financial(HttpServletRequest request, HttpServletResponse response)	{		try		{			GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");			LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");						String workEffortId=request.getParameter("workEffortId");			String borrowId=request.getParameter("borrowId");			String financial=request.getParameter("financial");			if(financial==null)			{				financial="";			}			String roleTypeId=request.getParameter("roleTypeId");			String fromDateS=request.getParameter("fromDate");			int year=Integer.parseInt(fromDateS.substring(0,4))-1900;			int month=Integer.parseInt(fromDateS.substring(5,7))-1;			int day=Integer.parseInt(fromDateS.substring(8,10));			int hour=Integer.parseInt(fromDateS.substring(11,13));			int minute=Integer.parseInt(fromDateS.substring(14,16));			int second=Integer.parseInt(fromDateS.substring(17,19));			Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);						//保存意见			GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));			borrow.set("financial",financial);			borrow.store();						//完成activity			Security security = dispatcher.getSecurity();			GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);			String partyId = (String)userLogin.getString("partyId");						if (!hasPermission(security, workEffortId, userLogin))			{				Debug.log("没有权限完成当前任务!");				return "error";			}						try			{				Map actResults = new HashMap();				WorkflowClient client=new WorkflowClient(delegator,dispatcher);				client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);			}			catch(WfException we)			{				Debug.log(we);				return "error";			}						return "success";		}		catch(Exception e)		{			Debug.log(e);			return "error";		}	}		public static String newborrow(HttpServletRequest request, HttpServletResponse response)	{		try		{			GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");			LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");			GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);						//新建记录			String borrowId=delegator.getNextSeqId("Borrow").toString();			Double reqsum=new Double(request.getParameter("reqsum"));			String bmemo=request.getParameter("bmemo");		        Timestamp bdate = UtilDateTime.nowTimestamp();		        Double actsum=new Double(0);		        String userLoginId=userLogin.getString("userLoginId");		        		        Map map=new HashMap();		        map.put("borrowId",borrowId);		        map.put("reqsum",reqsum);		        map.put("bmemo",bmemo);		        map.put("bdate",bdate);		        map.put("dman","");		        map.put("gman","");		        map.put("financial","");		        map.put("actsum",actsum);		        map.put("workEffortId","");		        map.put("userLoginId",userLoginId);			GenericValue borrow = delegator.create("Borrow",map);			borrow.store();									//启动process			dispatcher.runAsync("processBorrow", UtilMisc.toMap("borrowId",borrowId,"sum",reqsum));		}		catch(Exception e)		{			Debug.log(e);			return "error";		}				return "success";	}		public static String worklist(HttpServletRequest request, HttpServletResponse response)	{		GenericDelegator delegator=(GenericDelegator)request.getAttribute("delegator");		GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);				//取得partyAssignment		List partyWorkEfforts = null;				if (userLogin != null && userLogin.get("partyId") != null)		{			try			{				List constraints = new LinkedList();								constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));				constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));				partyWorkEfforts = delegator.findByAnd("WorkEffortAndPartyAssign", constraints, UtilMisc.toList("priority","workEffortId"));			}			catch (GenericEntityException e)			{				Debug.logWarning(e);				return "error";			}		}				if (partyWorkEfforts == null) partyWorkEfforts = new LinkedList();		request.setAttribute("partyAssignment",partyWorkEfforts);						//取得roleAssignment		List roleWorkEfforts = null;				if (userLogin != null && userLogin.get("partyId") != null)		{			try {				List constraints = new LinkedList();								constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));				constraints.add(new EntityExpr("roleTypeId", EntityOperator.NOT_EQUAL, "_NA_"));				constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_ACCEPTED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));				constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));				constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));				roleWorkEfforts = delegator.findByAnd("WorkEffortPartyAssignByRole", constraints, UtilMisc.toList("priority"));			}			catch (GenericEntityException e)			{				Debug.logWarning(e);				return "error";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -