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

📄 meetinfoaction.java

📁 基于J2EE的办公自动化系统。实现流程定义流程办理等。运用了hibernate+struts+spring框架综合运用的系统。
💻 JAVA
字号:
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl

package com.oa.module.meet.struts.action;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
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 org.apache.struts.upload.FormFile;

import com.oa.module.meet.hibernate.Tmeet;
import com.oa.module.meet.hibernate.Tmeetinfo;
import com.oa.module.meet.meetinfodao.MeetInfoInterfer;
import com.oa.module.meet.struts.form.MeetinfoForm;
import com.oa.module.pub.ectomere.XPage;

/**
 * MyEclipse Struts Creation date: 01-19-2008
 * 
 * XDoclet definition:
 * 
 * @struts.action path="/meetinfo" name="meetinfoForm"
 *                input="/Jsp_file/meet/meetinfo.jsp" parameter="task"
 *                scope="request" validate="true"
 * @struts.action-forward name="infolist" path="/Jsp_file/meet/meetinfolist.jsp"
 */
public class MeetinfoAction extends DispatchAction {

	// --------------------------------------------------------- Instance
	// Variables
	private MeetInfoInterfer infointer;

	// --------------------------------------------------------- Methods

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward query(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		MeetinfoForm meetinfoForm = (MeetinfoForm) form;
		int currentPage = 1;
		try {
			currentPage = Integer.parseInt(request.getParameter("currentPage"));
		} catch (Exception e) {
			currentPage = 1;
		}
		int count = 3;
		Tmeetinfo info = new Tmeetinfo();
		// 拷贝查询参数
		try {
			BeanUtils.copyProperties(info, meetinfoForm);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		XPage meetinfopage = infointer.getItemlist(currentPage, count, info);
		request.setAttribute("meetinfopage", meetinfopage);
		return mapping.findForward("infolist");
	}


	
	/**
	 * 转到修改页面
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward init(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		MeetinfoForm meetinfoForm = (MeetinfoForm) form;
		String miid = request.getParameter("mid");
		Tmeetinfo info = infointer.getItemById(Long.parseLong(miid));
		try {
			BeanUtils.copyProperties(meetinfoForm,info);
		} catch (IllegalAccessException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
		List listuser = infointer.userlist();
		request.setAttribute("listuser1", listuser);// 所有 员工
		
//		从会议纪要表中查找会议纪要信息
		List dlist = infointer.selectbyid(miid);
		//会议表中查询出会议信息
		List list = infointer.listbyid(miid);
		Map map = (Map) list.get(0);
		if(dlist.size()==0){

			// 开会人数组
			String temp = map.get("minuos").toString();
			String[] user = temp.split(",");
			List addmeet = new ArrayList();
			for (int i = 0; i < user.length; i++) {
				Map tempmap = infointer.addmeet(user[i]);
				addmeet.add(tempmap);
			}
			request.setAttribute("addmeet", addmeet);
			// 返回一个所有用户列表
			List userlist = infointer.userlist();
			for (int i = 0; i < user.length; i++) {
				for (int j = 0; j < userlist.size(); j++) {
					Map tempmap = (Map) userlist.get(j);
					String id = tempmap.get("uno").toString();
					if (user[i].equals(id)) {
						userlist.remove(j);
						break;
					}
				}
			}
			request.setAttribute("userlist", userlist);
		}else{
			Map detailmap = (Map) dlist.get(0);
			// 开会人数组
			String temp2 = detailmap.get("miunos").toString();
			String[] user2 = temp2.split(",");
			List addmeet2 = new ArrayList();
			for (int i = 0; i < user2.length; i++) {
				Map tempmap = infointer.addmeet(user2[i]);
				addmeet2.add(tempmap);
			}
			request.setAttribute("addmeet", addmeet2);
//			 返回一个所有用户列表
			List userlist = infointer.userlist();
			for (int i = 0; i < user2.length; i++) {
				for (int j = 0; j < userlist.size(); j++) {
					Map tempmap = (Map) userlist.get(j);
					String id = tempmap.get("uno").toString();
					if (user2[i].equals(id)) {
						userlist.remove(j);
						break;
					}
				}
			}
			request.setAttribute("userlist", userlist);
//			 文件域
			if (detailmap.get("miaffixname") != null
					&& detailmap.get("miaffixpath") != null) {
				String fname = detailmap.get("miaffixname").toString();
				String fpath = detailmap.get("miaffixpath").toString();
				String[] fnames = fname.split(",");
				String[] fpaths = fpath.split(",");
				List filelist = new ArrayList();
				for (int i = 0; i < fnames.length; i++) {
					Map tempmap = new HashMap();
					tempmap.put("miaffixname", fnames[i]);
					tempmap.put("miaffixpath", fpaths[i]);
					filelist.add(tempmap);
				}
				request.setAttribute("filelist", filelist);
				int size = filelist.size();
				request.setAttribute("size", String.valueOf(size));
			}
		}
		
		List rlist = infointer.allroom();
		request.setAttribute("roomlist", rlist);
		
		meetinfoForm.setTask("edit");
		return mapping.getInputForward();
	}
	
	
	/**
	 * 修改会议纪要处理
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		MeetinfoForm meetinfoForm = (MeetinfoForm) form;
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		String[] temp = request.getParameterValues("addmeet");
		String adduser = null;
		if (temp != null) {
			for (int t = 0; t < temp.length; t++) {
				if (adduser != null && !adduser.equals("")) {
					adduser = adduser + ',' + temp[t];
				} else {
					adduser = temp[t];
				}
			}
		}
		meetinfoForm.setMiunos(adduser);
		
		
		List meetlist = infointer.listbyid(String.valueOf(meetinfoForm.getMiid()));
		Map map = (Map) meetlist.get(0);
		String oldname = (String) map.get("miaffixname");
		String oldpath = (String) map.get("miaffixpath");

		Hashtable fileh = meetinfoForm.getMultipartRequestHandler()
				.getFileElements();
		String filePath = "";
		String filenames = "";
		String filepaths = "";
		int i = 0;
		for (Enumeration e = fileh.keys(); e.hasMoreElements();) {
			filePath = "";
			filePath = servlet.getServletContext().getRealPath(
					"/upload/meetfile/");// 取当前系统路径
			String key = (String) e.nextElement();
			Set set = fileh.entrySet();
			Iterator iterator = set.iterator();
			while (iterator.hasNext()) {
				Map.Entry entry = (Map.Entry) iterator.next();
				if (entry.getValue() != "") {
					FormFile file = (FormFile) entry.getValue();
					if (file.getFileSize() > 5000000) {
						out
								.println("<script>alert('上传的附件大小不能大于5M');window.history.back();</script>");
						return null;
					}
				}
			}
			try {
				FormFile file = (FormFile) fileh.get(key);
				String filename = file.getFileName().trim();
				if (filename != null && !filename.equals("")) {
					filenames = filenames + filename + ",";
					String temp1 = filename.substring(filename.lastIndexOf("."),
							filename.length());
					String filepath = System.currentTimeMillis() + i + temp1;
					filepaths = filepaths + filepath + ",";

					InputStream stream = file.getInputStream();
					filePath = filePath + "\\" + filepath;
					OutputStream outstream = new FileOutputStream(filePath);
					int byteread = 0;
					byte[] buffer = new byte[8192];
					while ((byteread = stream.read(buffer, 0, 8192)) != -1) {
						outstream.write(buffer, 0, byteread);
					}
					meetinfoForm.setMaffix(1);
					outstream.close();
					stream.close();
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			i++;
		}
		if (!filenames.equals("") && !filepaths.equals("")) {
			filenames = filenames.substring(0, filenames.length() - 1);
			filepaths = filepaths.substring(0, filepaths.length() - 1);
		}
		oldname = oldname + "," + filenames;
		oldpath = oldpath + "," + filepaths;
		meetinfoForm.setMiaffixname(oldname);
		meetinfoForm.setMiaffixpath(oldpath);
		
		Tmeetinfo info = new Tmeetinfo();
		try {
			BeanUtils.copyProperties(info,meetinfoForm);
		} catch (IllegalAccessException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
		boolean flag = infointer.update(info);
		if (flag) {
			return new ActionForward("/meetinfo.do?task=query", true);
		} else {
			return mapping.getInputForward();
		}
	}
	
	
	
	/**
	 * 会议详细信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward look(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		MeetinfoForm meetinfoForm = (MeetinfoForm) form;
		String miid = request.getParameter("mid");
		Tmeetinfo meetinfo = infointer.getItemById(Long.parseLong(miid));
		try {
			BeanUtils.copyProperties(meetinfoForm, meetinfo);
		} catch (IllegalAccessException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		//		
		// List listuser1 = meetinter.getuserlist(meetForm.getMid());
		// request.setAttribute("listuser1",listuser1);//主持 人

		List listuser = infointer.userlist();
		request.setAttribute("listuser1", listuser);// 所有 员工
		
		List list = infointer.listbyid(meetinfoForm.getMiid());
		if (list != null && list.size() > 0) {
			Map map = (Map) list.get(0);
			String temp = map.get("munos").toString();
			String[] user = temp.split(",");
			List addmeet = new ArrayList();
			for (int i = 0; i < user.length; i++) {
				Map tempadd = infointer.addmeet(user[i]);
				addmeet.add(tempadd);
				System.out.println(addmeet);
			}
			request.setAttribute("addmeet", addmeet);
			// meetForm.setMstarttime(map.get("mstarttime").toString());
			// meetForm.setMendtime(map.get("mendtime").toString());
			// meetForm.setMcontent(map.get("mcontent").toString());
			meetinfoForm.setRmid(Long.parseLong(map.get("rmid").toString()));

			List userlist = infointer.userlist();
			for (int i = 0; i < user.length; i++) {
				for (int j = 0; j < userlist.size(); j++) {
					Map tempmap = (Map) userlist.get(j);
					String id = tempmap.get("uno").toString();
					if (user[i].equals(id)) {
						userlist.remove(j);
						break;
					}
				}
			}
			request.setAttribute("listuser", userlist);

			if (map.get("miaffixname") != null && map.get("maffixpath") != null) {
				String fname = map.get("miaffixname").toString();
				String fpath = map.get("miaffixpath").toString();
				String[] fnames = fname.split(",");
				String[] fpaths = fpath.split(",");
				List filelist = new ArrayList();
				for (int i = 0; i < fpaths.length; i++) {
					Map tempmap = new HashMap();
					tempmap.put("miaffixname", fnames[i]);
					tempmap.put("miaffixpath", fpaths[i]);
					filelist.add(tempmap);
				}
				request.setAttribute("filelist", filelist);
				request.setAttribute("size", String.valueOf(fnames.length));
				System.out.println(String.valueOf(fnames.length));
			}
		}
		
		
		List rlist = infointer.allroom();
		request.setAttribute("roomlist", rlist);		
		return mapping.findForward("look");
	}

	public MeetInfoInterfer getInfointer() {
		return infointer;
	}

	public void setInfointer(MeetInfoInterfer infointer) {
		this.infointer = infointer;
	}

}

⌨️ 快捷键说明

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