public void performTask(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String forwardURL = ""; Message message = null; Connection conn = null; res.setContentType(sContentType); try { conn = DBManager.getDBConnection(); SfUserDTO userAccount = (SfUserDTO) SessionUtil.getUserAccount(req); Logger.logInfo("Excel submit servlet begin...."); RequestParser reqPar = new RequestParser(); reqPar.transData(req); UploadFile[] upFiles = null; UploadRow uploadRow; String conFilePath = PDAUtil.getCurUploadFilePath(conn); UploadFileSaver uploadFileSaver = reqPar.getFileSaver(); uploadFileSaver.saveFiles(conFilePath); uploadRow = uploadFileSaver.getRow(); upFiles = uploadRow.getFiles(); if (upFiles == null) { return; } else if (upFiles.length != 1 || upFiles[0].getFileName().equals("")) { return; } UploadFile uploadFile = upFiles[0]; String fileName = uploadFile.getAbsolutePath(); fileName = fileName.replaceAll("\\\\", "/"); forwardURL = "/public/windowClose.jsp?retValue=" + fileName; } catch (PoolException e) { e.printStackTrace(); } catch (UploadException e) { e.printStackTrace(); } catch (FileSizeException e) { e.printStackTrace(); } catch (ContainerException e) { e.printStackTrace(); } finally { DBManager.closeDBConnection(conn); setHandleMessage(req, message); ServletForwarder forwarder = new ServletForwarder(req, res); forwarder.forwardView(forwardURL); } }
private DTOSet getCheckedAssets(HttpServletRequest req, String matchType) throws ServletException { DTOSet dtos = new DTOSet(); try { RequestParser parser = new RequestParser(); CheckBoxProp checkProp = new CheckBoxProp("subCheck"); checkProp.setIgnoreOtherField(true); parser.setCheckBoxProp(checkProp); parser.transData(req); String[] systemids = parser.getParameterValues("systemId"); String[] assetIds = parser.getParameterValues("assetId"); if (systemids != null) { int checkedCount = systemids.length; for (int i = 0; i < checkedCount; i++) { TfEtsItemMatchRecDTO dto = new TfEtsItemMatchRecDTO(); dto.setSystemId(systemids[i]); dto.setAssetId(assetIds[i]); dto.setMatchType(matchType); // String flag = req.getParameter("unyokeFlag"); String flag = "1"; if (flag.equals("1")) { // 资产匹配撤销 dto.setOldFinanceProp(DictConstant.FIN_PROP_ASSETS); dto.setNewFinanceProp(DictConstant.FIN_PROP_UNKNOW); } else if (flag.equals("0")) { // 转资匹配撤销 dto.setOldFinanceProp(DictConstant.FIN_PROP_ASSETS); dto.setNewFinanceProp(DictConstant.FIN_PROP_PRJ); } dtos.addDTO(dto); } } } catch (UploadException ex) { ex.printLog(); throw new ServletException(ex); } catch (StrException ex) { ex.printLog(); throw new ServletException(ex); } catch (DTOException ex) { ex.printLog(); throw new ServletException(ex); } return dtos; }
/** * @param req HttpServletRequest * @param res HttpServletResponse * @throws ServletException * @throws IOException */ public void performTask(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String forwardURL = ""; Message message = SessionUtil.getMessage(req); Connection conn = null; try { SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req); Request2DTO req2DTO = new Request2DTO(); req2DTO.setDTOClassName(EamDhCheckLineDTO.class.getName()); EamDhCheckLineDTO dto = (EamDhCheckLineDTO) req2DTO.getDTO(req); String action = dto.getAct(); conn = getDBConnection(req); if (action.equals("")) { req.setAttribute(QueryConstant.QUERY_DTO, dto); forwardURL = LvecURLs.INS_CONFIRM_PAGE; } else if (action.equals(DzyhActionConstant.QUERY_ACTION)) { BaseSQLProducer sqlProducer = new OrderLineConfirmModel(user, dto); PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer); pageDAO.setDTOClassName(EamDhCheckLineDTO.class.getName()); pageDAO.setCalPattern(LINE_PATTERN); CheckBoxProp checkProp = new CheckBoxProp("subCheck"); checkProp.addDbField("HEADER_ID"); checkProp.addDbField("BARCODE"); checkProp.addDbField("CATALOG_VALUE_ID"); checkProp.addDbField("RESPONSIBILITY_USER"); checkProp.addDbField("RESPONSIBILITY_DEPT"); checkProp.addDbField("ORDER_NO"); pageDAO.setWebCheckProp(checkProp); pageDAO.produceWebData(); req.setAttribute(QueryConstant.QUERY_DTO, dto); forwardURL = LvecURLs.INS_CONFIRM_PAGE; } else if (action.equals(DzyhActionConstant.CONFIRM_ACTION)) { // 确认 if (user.getEmployeeNumber().equals("")) { message = getMessage(LvecMessageKeys.NO_EMPLOYEE_NUMBER); message.setIsError(true); message.setNeedBack(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } else { RequestParser parser = new RequestParser(); CheckBoxProp checkProp = new CheckBoxProp("subCheck"); checkProp.setIgnoreOtherField(true); parser.setCheckBoxProp(checkProp); parser.transData(req); req2DTO.setIgnoreFields(EamCheckTaskDTO.class); req2DTO.addIgnoreField("itemName"); // req2DTO.addIgnoreField("orderNo"); DTOSet orderLines = req2DTO.getDTOSet(parser); InstruConfirmDAO confirmDAO = new InstruConfirmDAO(user, dto, conn); confirmDAO.ConfirmInstrument(orderLines); message = confirmDAO.getMessage(); forwardURL = LvecURLs.INS_CONFIRM_SERVLET; forwardURL += "?act=" + DzyhActionConstant.QUERY_ACTION; } } else { message = getMessage(MsgKeyConstant.INVALID_REQ); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } } catch (PoolPassivateException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.POOL_PASSIVATE_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (DTOException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.DTO_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (QueryException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.QUERY_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (UploadException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.COMMON_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (StrException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.COMMON_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (DataHandleException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.SQL_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } finally { DBManager.closeDBConnection(conn); setHandleMessage(req, message); if (!forwardURL.equals("")) { ServletForwarder forwarder = new ServletForwarder(req, res); forwarder.forwardView(forwardURL); } } }