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

📄 serviceorderaction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.FINDEXCEPTION);
		}
		request.setAttribute("faultLevelList", faultLevelList);
		return mapping.findForward(forward);
	}

	/**
	 * 处理服务单hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward processServiceOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr);
		}
		try{
			serviceOrderMgr.newProcessCource(id, request);
			request.setAttribute("message", Constants.SAVESUCCESS);
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.SAVEFIALURE);
		}
		request.setAttribute("id", id);
		return viewServiceOrder(mapping, form, request, response);
	}
	
	/**
	 *	下载附件
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException 
	 */
	public ActionForward downloadFile(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		int soFileId = 0;
		String soFileIdStr = request.getParameter("soFileId");
		if(soFileIdStr!=null && !"".equals(soFileIdStr)){
			soFileId = Integer.parseInt(soFileIdStr);
		}
		ServiceOrderFile soFile = null;
		try{
			soFile = serviceOrderMgr.getSOFileById(soFileId);
		}catch(RuntimeException re){
			logger.warn(re.getMessage());
		}
		logger.debug(soFile.getFileName());
		String fileName = soFile.getFileName();
		File file = new File(soFile.getPath()+soFile.getFileName());
		if (file.exists() && soFile!=null) {
			logger.debug("下载文件: " + fileName);
			fileName = StringTool.toUTF8String(soFile.getFileName());
			InputStream is = new FileInputStream(file);
			int fileSize = (int) file.length();
			logger.debug("文件大小: " + fileSize + "kb");
			// 设置下载文件使用的报头域
			response.setContentType("application/x-msdownload");
			String disposition = "attachment;filename=" + fileName;
			response.setHeader("Content-Disposition", disposition);
			response.setContentLength(fileSize);
			try {
				// 得到响应对象的输出流,用于向客户端输出二进制数据
				ServletOutputStream sos = response.getOutputStream();
				byte[] data = new byte[2048];
				int len = 0;
				while ((len = is.read(data)) > 0) {
					sos.write(data, 0, len);
				}
				is.close();
				sos.close();
			} catch (SocketException se) {
				// 下载被用户中断
				logger.info("下载被用户中断" + se);
			}
		}else{
			response.getWriter().print("<script>alert('file is not exists')</script>");
			response.getWriter().print("<script>window.close()</script>");
		}
		return null;
	}
	
	//******************************************自定义选项*************************************************************//
	/**
	 * 创建服务单新选项 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward newServiceOrderOption(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "newServiceOrderOption";
		try{
			serviceOrderMgr.newServiceOrderOption(request);
		}catch(RuntimeException re){
			logger.warn(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		request.setAttribute("message", Constants.SAVESUCCESS);
		return mapping.findForward(forward);
	}
	
	/**
	 * 通过id取服务单新选项到页面 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward getServiceOrderOptionToPage(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "editServiceOrderOption";
		int userDefinedId = 0;
		String userDefinedIdStr = request.getParameter("userDefinedId");
		Object obj = request.getAttribute("userDefinedId");
		if (userDefinedIdStr != null && !"".equals(userDefinedIdStr)) {
			userDefinedId = Integer.parseInt(userDefinedIdStr);
		}else if(obj!=null){
			userDefinedId = Integer.parseInt(obj.toString());
		}
		UserDefined soUserDefined = new UserDefined();
		ServiceOrderDefinedVo serviceOrderDefinedVo = null;
		try {
			soUserDefined = serviceOrderMgr.getServiceOrderDAO()
					.getUserDefinedById(userDefinedId);//
			logger.debug(soUserDefined.getUserFields().size());
			logger.debug(soUserDefined.getUserFilters().size());
			serviceOrderDefinedVo = serviceOrderMgr
					.getServiceOrderDefinedVo(soUserDefined);
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.SEARCHOPTIONEXCEPTION);
		}
		request.setAttribute("serviceOrderDefinedVo", serviceOrderDefinedVo);
		return mapping.findForward(forward);
	}

	/**
	 * 编辑服务单新选项 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward editServiceOrderOption(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "newServiceOrderOption";
		int userDefinedId = 0;
		String userDefinedIdStr = request.getParameter("userDefinedId");
		if (userDefinedIdStr != null && !"".equals(userDefinedIdStr)) {
			userDefinedId = Integer.parseInt(userDefinedIdStr);
		}
		try {
			serviceOrderMgr.editServiceOrderOption(userDefinedId,request);
			request.setAttribute("message",Constants.MODIFYSUCCESS);
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.SEARCHOPTIONEXCEPTION);
		}
		request.setAttribute("userDefinedId",userDefinedId);
		return getServiceOrderOptionToPage(mapping, form, request, response);
	}
	
	//************************************************客户联系人******************************************************//
	/**
	 * 选择工程师 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward selectUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String forward = "selectUser";
		String familyName = request.getParameter("familyName");// 用户姓名
		String path = (String) request.getRequestURI();
		logger.debug("path===" + path);
		path = path + "?method=selectUser";
		if (familyName != null && !"".equals(familyName)) {
			path = path + "familyName=" + familyName;
		}
		String currentPage_str = request.getParameter("currentPage"); // 获取当前码
		logger.debug("--currentPage--:" + currentPage_str);
		int currentPage = 1; // 初始化
		if (currentPage_str != null && !"".equals(currentPage_str)) {
			currentPage = Integer.parseInt(currentPage_str);
		}
		logger.debug("==path==:" + path);
		int rowsPerPage = Constants.PAGECOUNT;
		Page userPage = null;
		try {
			userPage = serviceOrderMgr.getUserPage(familyName, path,
					currentPage, rowsPerPage);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(Constants.FINDUSER_EXCEPTION);
		}
		// 设置页面默认的id跟name
		if (userPage.getList().size() > 0) {
			User user = (User) userPage.getList().get(0);
			request.setAttribute("pageId", user.getId());
			request.setAttribute("pageName", user.getFamilyName());
		}
		request.setAttribute("familyName", familyName);
		request.setAttribute("userPage", userPage);
		return mapping.findForward(forward);
	}
	
	/**
	 * 查找客户hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward searchCustomers(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "customersList";
		String customerName = request.getParameter("customerName");
		if (customerName != null && !"".equals(customerName)) {
			try {
				customerName = URLDecoder.decode(customerName, "utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		String path = (String) request.getRequestURI();
		logger.debug("path===" + path);
		path = path + "?method=searchCustomers";
		if (customerName != null && !"".equals(customerName)) {
			path = path + "&customerName=" + customerName;
		}
		String currentPage_str = request.getParameter("currentPage"); // 获取当前码
		logger.debug("--currentPage--:" + currentPage_str);
		int currentPage = 1; // 初始化
		if (currentPage_str != null && !"".equals(currentPage_str)) {
			currentPage = Integer.parseInt(currentPage_str);
		}
		logger.debug("==path==:" + path);
		int rowsPerPage = Constants.PAGECOUNT;
		Page customersPage = null;
		try {
			customersPage = serviceOrderMgr.searchCustomers(customerName, path,
					currentPage, rowsPerPage);
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.GETCUSTOMEREXCEPTION);
		}
		request.setAttribute("customersPage", customersPage);
		return mapping.findForward(forward);
	}

	/**
	 * 查找联系人hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward searchContacters(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "contactersList";
		int customerId = 0;
		String customerIdStr = request.getParameter("customerId");
		String name = request.getParameter("name");
		if (name != null && !"".equals(name)) {
			try {
				name = URLDecoder.decode(name, "utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		String path = (String) request.getRequestURI();
		logger.debug("path===" + path);
		path = path + "?method=searchContacters";
		path = path + "&customerId=" + customerIdStr;
		if (name != null && !"".equals(name)) {
			path = path + "&name=" + name;
		}
		if (customerIdStr != null && !"".equals(customerIdStr)
				&& !"null".equals(customerIdStr)) {
			customerId = Integer.parseInt(customerIdStr);
		}
		String currentPage_str = request.getParameter("currentPage"); // 获取当前码
		logger.debug("--currentPage--:" + currentPage_str);
		int currentPage = 1; // 初始化
		if (currentPage_str != null && !"".equals(currentPage_str)) {
			currentPage = Integer.parseInt(currentPage_str);
		}
		logger.debug("==path==:" + path);
		int rowsPerPage = Constants.PAGECOUNT;
		Page contactersPage = null;
		try {
			contactersPage = serviceOrderMgr.searchContacters(customerId, name,
					path, currentPage, rowsPerPage);
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw new ApplicationException(Constants.FINDCONTACTEXCEPTION);
		}
		request.setAttribute("contactersPage", contactersPage);
		request.setAttribute("customerId", customerIdStr);
		return mapping.findForward(forward);
	}

	/**
	 * 联系人hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward viewContact(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String forward = "viewContact";
		int contactId = 0;
		String contactIdStr = request.getParameter("contactId");
		if (contactIdStr != null && !"".equals(contactIdStr)) {
			contactId = Integer.parseInt(contactIdStr);
		}
		try {
			CustomerContact customerContact = serviceOrderMgr
					.getContactById(contactId);
			// 根据修改人的ID查找上次修改人
			User modifyMan = serviceOrderMgr.getUserById(customerContact
					.getModifyManId());
			request.setAttribute("modifyMan", modifyMan);
			request.setAttribute("customerContact", customerContact);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		return mapping.findForward(forward);
	}

	/**
	 * 联系人hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward viewCustomer(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String forward = "viewCustomer";
		int customerId = 0;
		String customerIdStr = request.getParameter("customerId");
		if (customerIdStr != null && !"".equals(customerIdStr)) {
			customerId = Integer.parseInt(customerIdStr);
		}
		try {
			Customer customer = serviceOrderMgr.getCustomerById(customerId);
			User modifyMan = serviceOrderMgr.getUserById(customer
					.getModifyManId());
			request.setAttribute("customer", customer);
			request.setAttribute("modifyMan", modifyMan);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		return mapping.findForward(forward);
	}
	
}

⌨️ 快捷键说明

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