/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yyaccp.jbpm.web.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.yyaccp.jbpm.biz.ApproveBiz;
import com.yyaccp.jbpm.biz.QingJiaDanBiz;
import com.yyaccp.jbpm.biz.UserBiz;
import com.yyaccp.jbpm.biz.WorkFlowBiz;
import com.yyaccp.jbpm.entity.OaApprove;
import com.yyaccp.jbpm.entity.OaQingjiadan;
import com.yyaccp.jbpm.entity.OaUsers;
import com.yyaccp.jbpm.web.form.QingJiaForm;
/**
* MyEclipse Struts Creation date: 10-25-2008
*
* XDoclet definition:
*
* @struts.action path="/qingJia" name="qingJiaForm" input="/qingJia.jsp"
* parameter="method" scope="request" validate="true"
*/
public class QingJiaAction extends DispatchAction {
QingJiaDanBiz qjdBiz = null;
ApproveBiz approveBiz;
UserBiz userBiz;
WorkFlowBiz wkBiz;
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doQingJia(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QingJiaForm qingJiaForm = (QingJiaForm) form;// TODO Auto-generated
// method stub
OaQingjiadan qjd = qingJiaForm.getItem();
qjd.setOaUsers((OaUsers) request.getSession().getAttribute("userObj"));
System.out.println(qjd.getOaUsers());
qjdBiz.doQingJia(qjd);
request.setAttribute("message", "填写成功");
return mapping.findForward("index");
}
public ActionForward toAudit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QingJiaForm qingJiaForm = (QingJiaForm) form;// TODO Auto-generated
// method stub
String qjdId = request.getParameter("qjdId");
OaQingjiadan qjd = this.qjdBiz.findById(new Integer(qjdId));
qingJiaForm.setItem(qjd);
qingJiaForm.setTaskId(request.getParameter("taskId"));
qjd.setOaUsers((OaUsers) request.getSession().getAttribute("userObj"));
OaApprove a = this.approveBiz.findByQingjiadanId(qjd.getId());
qingJiaForm.setApproveNote(a.getApproveNote());
// 处理意见
String userId ="" + qjd.getOaUsers().getUserId();
List<String> items = new ArrayList<String>();
if (userBiz.isBoss(userId)) {
items.add("同意");
items.add("不同意");
} else if (userBiz.isManager(userId)) {
items.add("同意");
items.add("不同意");
items.add("重新填写");
} else { // is employee
items.add("改好了");
items.add("懒得请了");
}
qingJiaForm.setApproveItems(items);
return mapping.findForward("auditQingjia");
}
public ActionForward doAudit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QingJiaForm frm = (QingJiaForm) form;// TODO Auto-generated method
// stub
String approveNote = frm.getApproveNote();
String approveResult = frm.getApproveResult();
OaApprove approve = new OaApprove();
approve.setApproveNote(approveNote);
approve.setApproveResult(approveResult);
approve.setOaUsers((OaUsers) request.getSession().getAttribute(
"userObj"));
// 请假单ID
approve.setApproveProjectId(frm.getItem().getId());
System.out.println("approveNote=" + approveNote);
approveBiz.saveApprove(approve, frm.getTaskId());
request.setAttribute("taskList", wkBiz.getWaitTasks(""
+ approve.getOaUsers().getUserId()));
return mapping.findForward("taskList");
}
public ActionForward toAllProcessDefinition(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list = this.wkBiz.getAllQingJiaProcessDefinition();
request.setAttribute("list", list);
return mapping.findForward("allProcess");
}
public ActionForward toAllTask(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list = this.wkBiz.findTaskInstancesByProcessId(request.getParameter("processId"));
request.setAttribute("taskList", list);
System.out.println(list);
return mapping.findForward("taskList");
}
public ApproveBiz getApproveBiz() {
return approveBiz;
}
public void setApproveBiz(ApproveBiz approveBiz) {
this.approveBiz = approveBiz;
}
public QingJiaDanBiz getQjdBiz() {
return qjdBiz;
}
public void setQjdBiz(QingJiaDanBiz qjdBiz) {
this.qjdBiz = qjdBiz;
}
public UserBiz getUserBiz() {
return userBiz;
}
public void setUserBiz(UserBiz userBiz) {
this.userBiz = userBiz;
}
public WorkFlowBiz getWkBiz() {
return wkBiz;
}
public void setWkBiz(WorkFlowBiz wkBiz) {
this.wkBiz = wkBiz;
}
}