Esempio n. 1
0
  /**
   * Do action performance.
   *
   * @param mapping ActionMapping
   * @param form ActionForm
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   * @return ActionForward
   * @throws Exception exception
   */
  public ActionForward execute(
      final ActionMapping mapping,
      final ActionForm form,
      final HttpServletRequest request,
      final HttpServletResponse response)
      throws Exception {

    String prodCode = request.getParameter("prodCode");

    IcTapeDao icTapeDao = new IcTapeDao();
    CogDao cogDao = new CogDao();
    SapMasterCustomerDao sapMasterCustomerDao = new SapMasterCustomerDao();

    List<String> custList = new ArrayList<String>();
    List<String> extCustList = new ArrayList<String>();
    String custs = "";
    custList.addAll(icTapeDao.findCustByProdCode(prodCode));
    // custList.addAll(cogDao.findCustByProdCode(prodCode));

    for (String s : custList) {
      if (!extCustList.contains(s) && StringUtils.isNotEmpty(s)) {
        extCustList.add(s);
      }
    }

    for (String s : extCustList) {
      if (s != null && !s.equals("") && !s.equals("null")) {
        SapMasterCustomerTo sapMasterCustomerTo = sapMasterCustomerDao.findByVendorCode(s);
        if (sapMasterCustomerTo != null
            && StringUtils.isNotEmpty(sapMasterCustomerTo.getShortName())) {
          custs += "/" + sapMasterCustomerTo.getShortName();
        }
      }
    }

    if (custs.length() > 0) {
      custs = custs.substring(1);
    }

    List<String> cogCust = cogDao.findCustByProdCode(prodCode);
    extCustList = new ArrayList<String>();
    if (cogCust != null && cogCust.size() > 0) {
      for (String s : cogCust) {
        if (!extCustList.contains(s) && StringUtils.isNotEmpty(s)) {
          extCustList.add(s);
        }
      }
    }

    for (String s : extCustList) {
      custs += "/" + s;
    }

    if (custs.endsWith("/")) {
      custs = custs.substring(0, custs.length());
    }

    PrintWriter out = response.getWriter();
    out.print(Escape.escape(custs));

    return null;
  }