Ejemplo n.º 1
0
  public SQLModel getPageQueryModel() throws SQLModelException {
    SQLModel sqlModel = new SQLModel();
    List sqlArgs = new ArrayList();
    String sqlStr =
        "SELECT AITH.TRANS_NO,\n"
            + "       AIAH.TRANS_NO ALLOCATE_NO,\n"
            + "       AIFD.FREIGHT_ID,\n"
            + "       AIFD.ITEM_CODE,\n"
            + "       AIFD.DETAIL_ID,\n"
            + "       AIFD.TRANS_ID,\n"
            + "       AMS_PUB_PKG.GET_ORGNIZATION_NAME(AITH.FROM_ORGANIZATION_ID) ORGNIZATION_NAME,\n"
            + "       ESI.ITEM_NAME,\n"
            + "       ESI.ITEM_SPEC,\n"
            + "       AIFD.FREIGHT_QUANTITY,\n"
            + "       AIFD.FREIGHT_DATE,\n"
            + "       EFV.VALUE STATUS,\n"
            + "       DECODE(AIFD.RESEND_FLAG,'Y','已重寄','') REMARK\n"
            + "FROM   AMS_ITEM_FREIGHT_D  AIFD,\n"
            + "       AMS_ITEM_ALLOCATE_H AIAH,\n"
            + "       AMS_ITEM_TRANS_H    AITH,\n"
            + "       ETS_SYSTEM_ITEM     ESI,\n"
            + "       ETS_FLEX_VALUES     EFV,\n"
            + "       ETS_FLEX_VALUE_SET  EFVS\n"
            + "WHERE  AIFD.TRANS_ID = AIAH.TRANS_ID\n"
            + "       AND AIAH.SOURCE_ID = AITH.TRANS_ID\n"
            + "       AND ESI.ITEM_CODE = AIFD.ITEM_CODE\n"
            + "       AND AIFD.FREIGHT_STATUS = EFV.CODE\n"
            + "       AND EFVS.CODE = 'SPARE_ORDER_STATUS'\n"
            + "       AND AIAH.FROM_ORGANIZATION_ID = ?\n"
            + "       AND AIAH.TRANS_NO LIKE NVL(?, AIAH.TRANS_NO)\n"
            + "       AND AIAH.FROM_OBJECT_NO = NVL(?,AIAH.FROM_OBJECT_NO)\n"
            + "       AND AIFD.FREIGHT_DATE >= NVL(?, AIFD.FREIGHT_DATE)\n"
            + "       AND AIFD.FREIGHT_DATE <= NVL(?, AIFD.FREIGHT_DATE)\n"
            + "ORDER  BY AIFD.FREIGHT_DATE";
    sqlArgs.add(userAccount.getOrganizationId());
    sqlArgs.add(headerDTO.getTransNo());
    sqlArgs.add(headerDTO.getFromObjectNo());
    sqlArgs.add(headerDTO.getFromDate());
    sqlArgs.add(headerDTO.getSQLToDate());

    sqlModel.setSqlStr(sqlStr);
    sqlModel.setArgs(sqlArgs);
    return sqlModel;
  }
Ejemplo n.º 2
0
  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);
    }
  }