コード例 #1
0
  public void performTask(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    String forwardURL = "";
    Message message = SessionUtil.getMessage(req);
    Connection conn = null;
    try {
      conn = getDBConnection(req);
      SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req);
      Request2DTO req2DTO = new Request2DTO();
      req2DTO.setDTOClassName(AmsAssetsCJYCDTO.class.getName());
      AmsAssetsCJYCDTO dtoParameter = (AmsAssetsCJYCDTO) req2DTO.getDTO(req);
      AmsAssetsQJCJYCDAO dao = new AmsAssetsQJCJYCDAO(user, dtoParameter, conn);
      ServletConfigDTO sevletConfig = SessionUtil.getServletConfigDTO(req);
      dtoParameter.setFaCategory1(SinoConfig.getFaCat1Mis());
      dtoParameter.setFaCategory2(SinoConfig.getFaCat2Mis());
      dtoParameter.setFaCategory3(SinoConfig.getFaCat3Mis());

      String action = req.getParameter("act");
      action = StrUtil.nullToString(action);
      OptionProducer op = new OptionProducer(user, conn);
      int organizationId = StrUtil.strToInt(dtoParameter.getBookTypeCode());
      String companySelect = op.getAllOrganization(organizationId, true);
      req.setAttribute("OU", companySelect);
      String monthOption = op.getFromMonthOption(dtoParameter.getFromMonth());
      String tomonthOption = op.getFromMonthOption(dtoParameter.getToMonth());
      String bookTypeCode = dtoParameter.getBookTypeCode();
      String bookSelect = op.getAllBookTypeName(bookTypeCode, true);
      String catSegment1 = dtoParameter.getCatSegment1();
      String catSegment1Servlet = op.getUseField(catSegment1, true);
      req.setAttribute("CATSEGMENT1", catSegment1Servlet);
      req.setAttribute("BOOK_TYPE_CODE", bookSelect);
      req.setAttribute("FROM_MONTH_OPTION", monthOption);
      req.setAttribute("TO_MONTH_OPTION", tomonthOption);
      req.setAttribute("AMSBJTRANSNOHDTO", dtoParameter);
      if (action.equals("")) {
        forwardURL = "/newasset/assetsQJCJYC.jsp";
      } else if (action.equals(AssetsActionConstant.QUERY_ACTION)) {
        BaseSQLProducer sqlProducer = new AmsAssetsQJCJYCModel(user, dtoParameter);
        PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer);
        pageDAO.setCalPattern(LINE_PATTERN);
        pageDAO.setCountPages(false);
        pageDAO.produceWebData();
        req.setAttribute("AMSBJTRANSNOHDTO", dtoParameter);
        forwardURL = "/newasset/assetsQJCJYC.jsp";
      } else if (action.equals(AssetsActionConstant.EXPORT_ACTION)) {
        File file = dao.exportFile();
        WebFileDownload fileDown = new WebFileDownload(req, res);
        fileDown.setFilePath(file.getAbsolutePath());
        fileDown.download();
        file.delete();
      }
    } catch (DTOException ex) {
      ex.printLog();
      message = getMessage(AssetsMessageKeys.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 (PoolPassivateException ex) {
      ex.printLog();
      message = getMessage(AssetsMessageKeys.POOL_PASSIVATE_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (WebFileDownException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.COMMON_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (DataTransException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.COMMON_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } finally {
      DBManager.closeDBConnection(conn);
      setHandleMessage(req, message);
      ServletForwarder forwarder = new ServletForwarder(req, res);
      forwarder.forwardView(forwardURL);
    }
  }
コード例 #2
0
ファイル: BjdbdyServlet.java プロジェクト: starMagic/CQEAM
  public void performTask(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    String forwardURL = "";
    Message message = SessionUtil.getMessage(req);
    String action = StrUtil.nullToString(req.getParameter("act"));
    Connection conn = null;
    try {
      SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req);
      AmsItemAllocateHDTO dtoParameter = null;
      Request2DTO req2DTO = new Request2DTO();
      req2DTO.setDTOClassName(AmsItemAllocateHDTO.class.getName());
      dtoParameter = (AmsItemAllocateHDTO) req2DTO.getDTO(req);
      conn = getDBConnection(req);
      OptionProducer optProducer = new OptionProducer(user, conn);
      if (action.equals("")) {
        String orderStatus =
            optProducer.getDictOption("SPARE_ORDER_STATUS", dtoParameter.getTransStatus());
        req.setAttribute(WebAttrConstant.TRANS_STATUS, orderStatus);
        String invOption = optProducer.getInvOption(dtoParameter.getFromObjectNo());
        req.setAttribute(WebAttrConstant.INV_OPTION, invOption);
        forwardURL = "/nm/spare2/bjdbdy.jsp";
      } else if (action.equals(WebActionConstant.QUERY_ACTION)) {
        BaseSQLProducer sqlProducer = new BjdbdyModel(user, dtoParameter);
        PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer);
        pageDAO.setCalPattern(CalendarConstant.LINE_PATTERN);
        pageDAO.produceWebData();
        String orderStatus =
            optProducer.getDictOption("SPARE_ORDER_STATUS", dtoParameter.getTransStatus());
        req.setAttribute(WebAttrConstant.TRANS_STATUS, orderStatus);
        String invOption = optProducer.getInvOption(dtoParameter.getFromObjectNo());
        req.setAttribute(WebAttrConstant.INV_OPTION, invOption);
        forwardURL = "/nm/spare2/bjdbdy.jsp";
      } else if (action.equals(WebActionConstant.DETAIL_ACTION)) {
        BjswjyckDAO itemTransHDAO = new BjswjyckDAO(user, dtoParameter, conn);
        itemTransHDAO.setDTOClassName(AmsItemAllocateHDTO.class.getName());
        AmsItemAllocateHDTO amsItemTransH =
            (AmsItemAllocateHDTO) itemTransHDAO.getDataByPrimaryKey();
        if (amsItemTransH == null) {
          amsItemTransH = new AmsItemAllocateHDTO();
          message = getMessage(MsgKeyConstant.DATA_NOT_EXIST);
          message.setIsError(true);
        }
        req.setAttribute("AIT_HEADER", amsItemTransH);
        String freightDate = req.getParameter("freightDate");
        WebPageView wpv = new WebPageView(req, conn);
        wpv.setPrintProp(true);
        BaseSQLProducer sqlProducer = new BjswjyckModel(user, dtoParameter);
        wpv.produceWebData(sqlProducer.getDataByForeignKeyModel(dtoParameter.getTransId()));

        forwardURL = "/nm/spare2/bjdbdyDetail.jsp";
      } 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);
      message.setNeedBack(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (DTOException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.DTO_ERROR);
      message.setIsError(true);
      message.setNeedBack(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (QueryException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.QUERY_ERROR);
      message.setIsError(true);
      message.setNeedBack(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (SQLModelException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } finally {
      DBManager.closeDBConnection(conn);
      setHandleMessage(req, message);
      ServletForwarder forwarder = new ServletForwarder(req, res);
      forwarder.forwardView(forwardURL);
    }
  }