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

📄 onlineorderaction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//			message = re.getMessage();
//			throw new ApplicationException(Constants.COMMENT_EXCEPTION);
//		}
//		request.setAttribute("id",id);
//		request.setAttribute("message",message);
//		return viewOnlineOrder(mapping, form, request, response);
//	}
	
	
//	/**
//	 * 通过类别查找服务单
//	 * 
//	 * @param mapping
//	 * @param form
//	 * @param request
//	 * @param response
//	 * @return ActionForward
//	 */
//	public ActionForward getByCategory(ActionMapping mapping, ActionForm form,
//			HttpServletRequest request, HttpServletResponse response) {
//		int id = Integer.parseInt(request.getParameter("id"));
//		String id_str = Integer.toString(id);
//		String name = request.getParameter("name");
//		String path = request.getRequestURI();
//		path = path + "?method=getByCategory&id=" + id_str + "&name=" + name;
//		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);
//		}
//		int rowsPerPage = 10;// 定义每页显示的记录数
//		System.out.println("---------------------------按 " + name + " 查询");
//		Page orderPage = null;
//		try {
//			Category category = categoryMgr.getCategoryDAO().findById(id);
//			orderPage = onlineOrderMgr.findByCategory(
//					category, path, currentPage, rowsPerPage);
//		} catch (RuntimeException re) {
//			logger.debug(re.getMessage());
//		}
//		request.setAttribute("orderPage", orderPage);
//		request.setAttribute("categoryName", name);
//		return mapping.findForward("orderList");
//	}
	
//	/**
//	 * 点击服务清单所查看到的服务详细信息
//	 * 
//	 */
//	
//	public ActionForward detail(ActionMapping mapping, ActionForm form,
//			HttpServletRequest request, HttpServletResponse response)
//			throws ApplicationException {
//		String forward = "detail";
//		ServiceOrder serviceOrder = null;
//		try {
//			serviceOrder = onlineOrderMgr.getServiceOrderDAO().findById(Integer.parseInt(request.getParameter("id")));
//		} catch (RuntimeException re) {
//			logger.error(re.getMessage());
//		}
//		request.setAttribute("serviceOrder", serviceOrder);
//		return mapping.findForward(forward);
//	}
//	/**
//	 * 通过关键字收索服务单
//	 * 
//	 * @param mapping
//	 * @param form
//	 * @param request
//	 * @param response
//	 * @return ActionForward
//	 */
//	public ActionForward findByKeyword(ActionMapping mapping, ActionForm form,
//			HttpServletRequest request, HttpServletResponse response)
//			throws ApplicationException {
//		String keyword = request.getParameter("keyword");
//		String path = request.getRequestURI();
//		path = path + "?method=findByKeyword&keyword=" + keyword;
//		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);
//		}
//		int rowsPerPage = 10;//定义每页显示的记录数
//		Page page = null;
//		try{
//			page = onlineOrderMgr.findOrderByKeyword(keyword, path, currentPage, rowsPerPage);
//			request.setAttribute("searchResultPage", page);
//			request.setAttribute("keyword", keyword);
//		}catch(RuntimeException re){
//			logger.debug(re.getMessage());
//		}
//		
//		return mapping.findForward("searchResult");
//	}
	/**
	 * 客户登录后rightFrame显示的内容
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward getToCustMain(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String forward = "newOnlineOrder";
		List<CustomerContact> customerContactList = null;
		try {
			String serialNum = new SimpleDateFormat("yyyyMMdd")
					.format(new Date());
			ServiceOrder serviceOrder = onlineOrderMgr.getServiceOrderByMaxId();//取最大ID问题单
			if (serviceOrder != null) {
				Integer id = serviceOrder.getId() + 1;
				if (id.toString().length() == 1) {
					serialNum = serialNum + "000" + id.toString();
				} else if (id.toString().length() == 2) {
					serialNum = serialNum + "00" + id.toString();
				} else if (id.toString().length() == 3) {
					serialNum = serialNum + "0" + id.toString();
				}
			} else {
				serialNum = serialNum + "0001";
			}
			String createTime = new SimpleDateFormat("yyyy年MM月dd日hh时mm分")
					.format(new Date());
			CustAccount custAccount = OnlineSessionMgr.getCustAccountSession(request);
			if(custAccount!=null){
			customerContactList = onlineOrderMgr.getContactByCustomerId(custAccount.getCustomer().getId());
			logger.debug("该客户的联系人有:"+customerContactList.size());
			}
			request.setAttribute("serialNum", serialNum);
			request.setAttribute("createTime", createTime);
			request.setAttribute("customerContactList", customerContactList);
		} catch (DateFormatException dfe) {
			logger.debug(dfe.getMessage());
			throw new ApplicationException(dfe.getMessage());
		}
		return mapping.findForward(forward);
	}
	
	/**
	 *	下载附件
	 * 
	 * @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 = onlineOrderMgr.getServiceOrderDAO().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;
	}
	
	/**
	 *	取在线问题单到页面编辑
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException 
	 */
	public ActionForward getOnlineOrderToEdit(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		String forward = "editOnlineOrder";
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr); 
		}
		ServiceOrder myOnlineOrder = null;
		Set<ServiceOrderFile> serviceOrderFileSet =null;
		List<CustomerContact> customerContactList = null;
		int sofSize = 0;
		try{
			myOnlineOrder = onlineOrderMgr.getServiceOrderDAO().findById(id);
			serviceOrderFileSet = myOnlineOrder.getServiceOrderFiles();
			sofSize = serviceOrderFileSet.size();
			CustAccount custAccount = OnlineSessionMgr.getCustAccountSession(request);
			if(custAccount!=null){
			customerContactList = onlineOrderMgr.getContactByCustomerId(custAccount.getCustomer().getId());
			logger.debug("该客户的联系人有:"+customerContactList.size());
			}
		} catch (RuntimeException re) {
			logger.warn(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		request.setAttribute("myOnlineOrder",myOnlineOrder);
		request.setAttribute("serviceOrderFileSet",serviceOrderFileSet);
		request.setAttribute("sofSize",sofSize);
		request.setAttribute("customerContactList", customerContactList);
		return mapping.findForward(forward);
	}
	
	/**
	 *	取在线问题单到页面编辑
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException 
	 */
	public ActionForward editOnlineOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr); 
		}
		//判断上传的文件是否符合要求
		String resultMsg = onlineOrderMgr.checkFile(form);
		if(resultMsg!=null){
			request.setAttribute("message",resultMsg);
			return viewOnlineOrder(mapping, form, request, response);
		}
		try{
			onlineOrderMgr.editOnlineOrder(form, request);
			request.setAttribute("message",Constants.MODIFYSUCCESS);
		} catch (RuntimeException re) {
			logger.warn(re.getMessage());
		}
		request.setAttribute("id",id);
		return viewOnlineOrder(mapping, form, request, response);
	}
}

⌨️ 快捷键说明

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