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

📄 serviceorderaction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		logger.debug("开始取服务单");
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr);
		}
		ServiceOrder serviceOrder = new ServiceOrder();
		User visiter = null;
		try {
			serviceOrder = serviceOrderMgr.getServiceOrderDAO().findById(id);
			visiter = SessionMgr.getCustSession(request);
			if (visiter != null) {
				serviceOrder.setVisiter(visiter);
			}
			logger.debug("要取的ID是==" + id);
			if (serviceOrderForm.getVisitTime() != null) {
				serviceOrder.setVisitTime(DateTimeTool
						.getDateByStr2(serviceOrderForm.getVisitTime()));
			}
			serviceOrder.setReason(serviceOrderForm.getReason());// 原因
			serviceOrder.setSatisfaction(serviceOrderForm.getSatisfaction());
			serviceOrder.setState(Constants.SERVICE_ORDER_STATE_HAD_VISIT);// 设置此时的状态为已回访
			serviceOrderMgr.updateServiceOrder(serviceOrder);
			request.setAttribute("message", Constants.VIVIT_SUCCESS);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(
					Constants.MODIFY_SERVICEORDER_EXCEPTION);
		}
		request.setAttribute("id", id);
		request.setAttribute("serviceOrder", serviceOrder);
		return viewServiceOrder(mapping, form, request, response);
	}

	/**
	 * 取服务单到页面编辑 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 * @throws InvocationTargetException
	 * @throws IllegalAccessException
	 */
	public ActionForward getServiceOrderToEdit(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException,
			IllegalAccessException, InvocationTargetException {
		String forward = "editServiceOrder";
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr);
		}
		List<Category> categoryList = null;
		List<FaultLevel> faultLevelList = null;
		List<Source> sourceList = null;
		Set<ProcessCource> processCourceSet = null;
		Set<ServiceOrderFile> serviceOrderFileSet = null;// 附件
		ServiceOrder serviceOrder = new ServiceOrder();
		User currentUser = SessionMgr.getCustSession(request);
		User creater = new User();
		int sofSize = 0;
		try {
			serviceOrder = serviceOrderMgr.getServiceOrderDAO().findById(id);// 取要修改的服务单
			creater = serviceOrderMgr.getUserById(serviceOrder.getCreaterId());
			processCourceSet = serviceOrder.getProcessCources();
			serviceOrderFileSet = serviceOrder.getServiceOrderFiles();
			logger.debug("处理过程个数是:" + serviceOrder.getProcessCources().size());
			sofSize = serviceOrderFileSet.size();
			categoryList = categoryMgr.findAll();
			faultLevelList = faultLevelMgr.findAll();
			sourceList = sourceMgr.findAll();
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(
					Constants.MODIFY_SERVICEORDER_EXCEPTION);
		}
		request.setAttribute("creater",creater);
		request.setAttribute("currentUser", currentUser);
		request.setAttribute("serviceOrder", serviceOrder);
		request.setAttribute("categoryList", categoryList);
		request.setAttribute("faultLevelList", faultLevelList);
		request.setAttribute("sourceList", sourceList);
		request.setAttribute("processCourceSet", processCourceSet);
		request.setAttribute("serviceOrderFileSet", serviceOrderFileSet);
		request.setAttribute("sofSize",sofSize);
		return mapping.findForward(forward);
	}

	/**
	 * 编辑服务单 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 * @throws InvocationTargetException
	 * @throws IllegalAccessException
	 */
	public ActionForward editServiceOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		ServiceOrderForm serviceOrderForm = (ServiceOrderForm) form;
		try {
			serviceOrderMgr.editServiceOrder(serviceOrderForm, form, request);
			logger.debug("修改服务单成功");
			request.setAttribute("id", serviceOrderForm.getId());
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(
					Constants.MODIFY_SERVICEORDER_EXCEPTION);
		}
		request.setAttribute("message", Constants.MODIFYSUCCESS);
		return viewServiceOrder(mapping, form, request, response);
	}

	/**
	 * 接单 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward receiveServiceOrder(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 {
			ServiceOrder serviceOrder = serviceOrderMgr.findById(id);
			serviceOrder.setState(Constants.SERVICE_ORDER_STATE_DONECENTER);// 接单
			serviceOrderMgr.updateServiceOrder(serviceOrder);
			logger.debug("接收服务单成功");
			request.setAttribute("message", Constants.RECEIVESUCCESS);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(
					Constants.RECEIVE_SERVICEORDER_EXCEPTION);
		}
		request.setAttribute("id", id);
		return viewServiceOrder(mapping, form, request, response);
	}

	/**
	 * 处理完毕 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward processComplete(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 {
			ServiceOrder serviceOrder = serviceOrderMgr.findById(id);
			serviceOrder.setState(Constants.SERVICE_ORDER_STATE_DONE_END);// 处理完毕
			serviceOrderMgr.updateServiceOrder(serviceOrder);
			logger.debug("处理完毕");
			request.setAttribute("message", Constants.SAVESUCCESS);
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
			throw new ApplicationException(
					Constants.RECEIVE_SERVICEORDER_EXCEPTION);
		}
		request.setAttribute("id", id);
		return viewServiceOrder(mapping, form, request, response);
	}


	/**
	 * 查看服务单 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward viewServiceOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "viewServiceOrder";
		int id = 0;
		String idStr = request.getParameter("id");
		Object idStr2 = request.getAttribute("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr);
		} else if (idStr2 != null) {
			logger.debug(idStr2);
			id = Integer.parseInt(idStr2.toString());
		}
		ServiceOrder serviceOrder = new ServiceOrder();
		Set<ServiceOrderFile> serviceOrderFileSet = null;
		Set<ProcessCource> processCourceSet = null;
		User user = SessionMgr.getCustSession(request);
		User creater = new User();
		try {
			serviceOrder = serviceOrderMgr.findById(id);
			serviceOrderFileSet = serviceOrder.getServiceOrderFiles();
			processCourceSet = serviceOrder.getProcessCources();
			if(serviceOrder.getCreaterId()!=null){
			creater = serviceOrderMgr.getUserById(serviceOrder.getCreaterId());
			}
			logger.debug("处理过程有:"+serviceOrder.getProcessCources().size()+"条");
			
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
		}
		request.setAttribute("user",user);
		request.setAttribute("creater",creater);
		request.setAttribute("serviceOrder", serviceOrder);
		request.setAttribute("serviceOrderFileSet", serviceOrderFileSet);
		request.setAttribute("processCourceSet", processCourceSet);
		return mapping.findForward(forward);
	}

	/**
	 * 搜索服务单 hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward searchServiceOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "serviceOrderIndex";
		int userDefinedId = 0;
		String userDefinedIdStr = request.getParameter("userDefinedId");
		if (userDefinedIdStr != null && !"".equals(userDefinedIdStr)) {
			userDefinedId = Integer.parseInt(userDefinedIdStr);
		}
		String path = request.getRequestURI();
		path = path + "?method=searchServiceOrder";
		path = path + "&userDefinedId=" + userDefinedId;
		String currentPage_str = request.getParameter("currentPage");
		int currentPage = 1; // 初始化
		if (currentPage_str != null && !"".equals(currentPage_str)) {
			currentPage = Integer.parseInt(currentPage_str);
		}
		int rowsPerPage = Constants.SERVICE_ORDER_PAGECOUNT;
		Page soPage = null;
		UserDefined userDefined = null;
		Set<UserFilter> userFilterSet = null;
		Set<UserField> userFiledSet = null;
		String[] serviceOrderField = null;
		int type = Constants.ALLSERVICEORDER_INT;// 表示取服务单自定义选项
		List<UserDefined> userDefinedList = new ArrayList<UserDefined>();
		User user = SessionMgr.getCustSession(request);
		// 2009-02-09 add 数据范围
		Rights rights = SessionMgr.getJspRightsControl(request).get("4")
				.getRightsMap().get("404");
		String style = rights.getStyle();
		try {
			String userIds = authorizationMgr.findUserDataRange(rights.getId(),
					user);
			userDefined = serviceOrderMgr.getServiceOrderDAO()
					.getUserDefinedById(userDefinedId);
			userFilterSet = userDefined.getUserFilters();// 过滤条件
			userFiledSet = userDefined.getUserFields();// 显示的table
			logger.debug(userFilterSet.size());
			logger.debug(userFiledSet.size());
			Iterator<UserField> ufiled = userFiledSet.iterator();
			while (ufiled.hasNext()) {
				serviceOrderField = ufiled.next().getFieldName().split(",");
			}
			soPage = serviceOrderMgr.searchServiceOrder(user.getId(), userIds, userFilterSet,
					path, currentPage, rowsPerPage);
			userDefinedList = serviceOrderMgr.getServiceOrderDAO()
					.getUserDefined(type, user);
			logger.debug(soPage.getList().size());
		} catch (RuntimeException re) {
			logger.debug(re.getMessage());
		}
		request.setAttribute("userDefinedList", userDefinedList);
		request.setAttribute("soPage", soPage);
		request.setAttribute("userDefinedId", userDefinedId);
		request.setAttribute("serviceOrderField", serviceOrderField);
		return mapping.findForward(forward);
	}
	
	/**
	 * 取得问题单进行派单hwb
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward getServiceOrderToAssign(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String forward = "assignServiceOrder";
		int id = 0;
		String idStr = request.getParameter("id");
		if (idStr != null && !"".equals(idStr)) {
			id = Integer.parseInt(idStr);
		}
		List<Category> categoryList = null;
		List<FaultLevel> faultLevelList = null;
		List<Source> sourceList = null;
		ServiceOrder serviceOrder = null;
		Set<ServiceOrderFile> serviceOrderFileSet = null;
		User user = SessionMgr.getCustSession(request);
		try{
			serviceOrder = serviceOrderMgr.findById(id);
			serviceOrderFileSet = serviceOrder.getServiceOrderFiles();
			logger.debug("该问题单共:"+serviceOrderFileSet.size()+"个文件");
			categoryList = categoryMgr.findAll();
			faultLevelList = faultLevelMgr.findAll();
			sourceList = sourceMgr.findAll();
		}catch(RuntimeException re){
			logger.debug(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		request.setAttribute("user",user);
		request.setAttribute("serviceOrder",serviceOrder);
		request.setAttribute("serviceOrderFileSet",serviceOrderFileSet);
		request.setAttribute("categoryList",categoryList);
		request.setAttribute("faultLevelList",faultLevelList);
		request.setAttribute("sourceList",sourceList);
		return mapping.findForward(forward);
	}
	
	/**
	 * 派单hwb
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward assignServiceOrder(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		ServiceOrderForm serviceOrderForm = (ServiceOrderForm) form;
		int userId = 0;
		String userIdStr = request.getParameter("userId");
		if(userIdStr!=null && !"".equals(userIdStr)){
			userId = Integer.parseInt(userIdStr);
		}
		logger.debug("id是:"+serviceOrderForm.getId());
		try {
			ServiceOrder serviceOrder = serviceOrderMgr.findById(serviceOrderForm.getId());
			serviceOrder.setState(Constants.SERVICE_ORDER_STATE_NO_DONE);
			if(serviceOrderForm.getContactId()!=0){
				serviceOrder.setCustomerContact(serviceOrderMgr.getContactById(serviceOrderForm.getContactId()));
			}
			if(serviceOrderForm.getCategoryId()!=0){
				serviceOrder.setCategory(categoryMgr.findById(serviceOrderForm.getCategoryId()));
			}
			if(serviceOrderForm.getSourceId()!=0){
				serviceOrder.setSource(sourceMgr.findById(serviceOrderForm.getSourceId()));
			}
			if(serviceOrderForm.getFaultLevelId()!=0){
				serviceOrder.setFaultLevel(faultLevelMgr.findById(serviceOrderForm.getFaultLevelId()));
			}
			if(serviceOrderForm.getTimeSliceStr()!=null){
				serviceOrder.setTimeSlice(DateTimeTool.getDateByStr2(serviceOrderForm.getTimeSliceStr()));
			}
			if(userId!=0){
				serviceOrder.setEngineer(serviceOrderMgr.getUserById(userId));
			}
			User user = SessionMgr.getCustSession(request);
			if(user!=null){
				serviceOrder.setCreaterId(user.getId());
				serviceOrder.setName(user.getFamilyName());
			}
			serviceOrderMgr.updateServiceOrder(serviceOrder);
			request.setAttribute("message",Constants.SAVESUCCESS);
		} catch (RuntimeException re) {
			logger.warn(re.getMessage());
			throw new ApplicationException(re.getMessage());
		}
		request.setAttribute("id",serviceOrderForm.getId());
		return viewServiceOrder(mapping, form, request, response);
	}
	
	// 取所有的故障级别
	public ActionForward searchFaultLevel(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		String forward = "faultLevelList";
		List<FaultLevel> faultLevelList = null;
		try {
			faultLevelList = faultLevelMgr.findAll();

⌨️ 快捷键说明

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