/**
   * (non-Javadoc)
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public ActionForward executeme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    errors.clear();
    errors.add("header", new ActionError("errors.header"));
    errors.add("footer", new ActionError("errors.footer"));

    HttpSession hs = request.getSession();
    String uname = (String) hs.getAttribute("userid");

    // TODO 临时用来监测用
    long l_begin, l_end;
    l_begin = System.currentTimeMillis();
    commsearch.util.CommDate cdtemp = new commsearch.util.CommDate();
    commsearch.util.CommActionLog.setTempLog(
        Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
        uname,
        hs.getId(),
        "PrintEipdtl",
        "B",
        "LYC0000000",
        0);

    if (uname == null) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC5555555",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
    if (uname.trim().equals("")) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC6666666",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }

    try {

      PropertyUtils.setSimpleProperty(form, "pagerow", "32");

      String temp = (String) request.getParameter("selectwhere");

      String stemp = temp;

      if (stemp == null) stemp = "";
      if (stemp.equals("")) {
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC3333333",
            l_end - l_begin);
        return (mapping.findForward("err"));
      }

      // temp=CommonTools.stringReplace(temp,"'","'");
      DataBean dbBean = new DataBean();
      String ss = "";
      if (temp.indexOf("EIVIVN") != -1) {
        try {
          dbBean.executeSelect("select eivstr,eivnum,eivtyp from eivdtl where " + temp);
        } catch (Exception e) {
          errors.add("errormessage", new ActionError("Datebase.readdb"));
          saveErrors(request, errors);
          //								TODO 临时用来监测用
          l_end = System.currentTimeMillis();
          commsearch.util.CommActionLog.setTempLog(
              Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
              uname,
              hs.getId(),
              "PrintEipdtl",
              "C",
              "LYC9999991",
              l_end - l_begin);
          return (mapping.findForward("success"));
        }
        for (int i = 0; i < dbBean.getRowCount(); i++) {
          ss = ss + "OR (EIPSTR='" + dbBean.getElementValue(i, "eivstr").trim() + "' AND ";
          ss = ss + " EIPNUM='" + dbBean.getElementValue(i, "eivnum").trim() + "' AND ";
          ss = ss + " EIPTYP='" + dbBean.getElementValue(i, "eivtyp").trim() + "')";
        }
        ss = ss.substring(2);
        temp = ss;
      }

      PropertyUtils.setSimpleProperty(form, "selectwhere", temp);

      if (setFormbeen(form, request, temp, uname).equals("0")) {
        saveErrors(request, errors);
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC8888881",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }
      log.debug("成功刷新页面");

      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC8888882",
          l_end - l_begin);
      return (mapping.findForward("success"));

    } catch (Exception e) {
      e.printStackTrace();
      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "C",
          "LYC9999999",
          l_end - l_begin);
      errors.add("errormessage", new ActionError("OrderIn.formbean"));
      saveErrors(request, errors);
      return (mapping.findForward("success"));
    }
  }
  /**
   * (non-Javadoc)
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public ActionForward executeme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    errors.clear();
    errors.add("header", new ActionError("errors.header"));
    errors.add("footer", new ActionError("errors.footer"));

    HttpSession hs = request.getSession();
    String uname = (String) hs.getAttribute("userid");

    // TODO 临时用来监测用
    long l_begin, l_end;
    l_begin = System.currentTimeMillis();
    commsearch.util.CommDate cdtemp = new commsearch.util.CommDate();
    commsearch.util.CommActionLog.setTempLog(
        Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
        uname,
        hs.getId(),
        "ReturnOrder",
        "B",
        "LYC0000000",
        0);

    if (uname == null) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //				TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC5555555",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
    if (uname.trim().equals("")) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //				TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC6666666",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }

    try {
      PropertyUtils.setSimpleProperty(form, "message", "0");

      Date now = new Date();
      PropertyUtils.setSimpleProperty(
          form, "nowdate", com.idn.util.FormatDate.format(now, "yyyy-MM-dd"));

      String temp = request.getParameter("eponum");
      String queryid = request.getParameter("queryid");
      String selectwhere = request.getParameter("selectwhere");

      if (selectwhere == null) {
        queryid = (String) PropertyUtils.getSimpleProperty(form, "queryid");
        selectwhere = (String) PropertyUtils.getSimpleProperty(form, "selectwhere");
      }
      String stemp = selectwhere;

      if (stemp == null) stemp = "";
      if (stemp.equals("")) {
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC3333333",
            l_end - l_begin);
        return (mapping.findForward("err"));
      }

      PropertyUtils.setSimpleProperty(form, "queryid", queryid);
      PropertyUtils.setSimpleProperty(form, "selectwhere", selectwhere);

      String flag = ((String) PropertyUtils.getSimpleProperty(form, "flag")).trim();

      if (flag.equals("")) {
        setFormbeen(form, request, selectwhere, uname);
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC8888881",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }

      String epoflg = (String) PropertyUtils.getSimpleProperty(form, "epoflg");
      String freeformstate = (String) PropertyUtils.getSimpleProperty(form, "freeformstate");

      String eponum = (String) PropertyUtils.getSimpleProperty(form, "eponum");
      String epostr = (String) PropertyUtils.getSimpleProperty(form, "epostr");
      String epostn = (String) PropertyUtils.getSimpleProperty(form, "epostn");
      String eposdt = (String) PropertyUtils.getSimpleProperty(form, "eposdt");
      String epordt = (String) PropertyUtils.getSimpleProperty(form, "epordt");

      eposdt = CommonTools.stringReplace(eposdt, "-", "").trim();
      eposdt = eposdt.substring(2);
      epordt = CommonTools.stringReplace(epordt, "-", "").trim();
      epordt = epordt.substring(2);

      String epordtm = (String) PropertyUtils.getSimpleProperty(form, "epordtmshow");
      String epordtm2 = (String) PropertyUtils.getSimpleProperty(form, "epordtm2show");
      String operator = (String) PropertyUtils.getSimpleProperty(form, "operatorid");
      String operdate = (String) PropertyUtils.getSimpleProperty(form, "operdate");
      String opertime = (String) PropertyUtils.getSimpleProperty(form, "opertime");

      // SQLBean sis=new SQLBean();

      DataBean dbBean = new DataBean();
      String strsql1 = "select * from ORDERR where " + selectwhere + "";
      try {
        dbBean.executeSelect(strsql1);
      } catch (Exception e) {
        e.printStackTrace();
        errors.add("errormessage", new ActionError("Datebase.readdb"));
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC8888882",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }

      String strsql[] = new String[1];
      if (dbBean.getRowCount() == 0) {
        strsql[0] =
            "insert into ORDERR (eponum,epostr,epostn,eposdt,epordt,epordtm,epoflg,operator,operdate,opertime,epordtm2) values('"
                + eponum
                + "' ,'"
                + epostr
                + "' ,'"
                + epostn
                + "','"
                + eposdt
                + "','"
                + epordt
                + "','"
                + epordtm
                + "','0','"
                + operator
                + "','"
                + operdate
                + "','"
                + opertime
                + "','"
                + epordtm2
                + "')";
        // 第一次进入并且orderr中不存在记录
        // int retrunint1=sis.executeSQL(strsql);

        // 写日志(XIAOAI处理)
        commsearch.util.CommActionLog cal = new commsearch.util.CommActionLog();

        cal.setAct_user(uname);
        cal.setAct_from("homeworldReturnOrder");
        cal.setAct_do("INS");
        cal.setAct_key(temp);
        cal.setAct_table("ORDERR");
        cal.setAct_ip(request.getRemoteAddr());
        cal.setAct_memo("回复插入定单编号为" + temp);
        cal.setAct_me("");
        cal.setActionLog();
      } else {
        operator = uname;
        operdate = com.idn.util.FormatDate.format(now, "yyMMdd");
        opertime = com.idn.util.FormatDate.format(now, "hh:mm:ss");

        strsql[0] =
            "update ORDERR set epotrf='', epordt='"
                + epordt
                + "',epordtm='"
                + epordtm
                + "',epordtm2='"
                + epordtm2
                + "', operdate='"
                + operdate
                + "',opertime='"
                + opertime
                + "',operator='"
                + operator
                + "' where eponum='"
                + eponum
                + "'";

        // int returnint=sis.executeSQL(strsql);

        // 写日志(XIAOAI处理)
        commsearch.util.CommActionLog cal = new commsearch.util.CommActionLog();

        cal.setAct_user(uname);
        cal.setAct_from("homeworldReturnOrder");
        cal.setAct_do("UPD");
        cal.setAct_key(temp);
        cal.setAct_table("ORDERR");
        cal.setAct_ip(request.getRemoteAddr());
        cal.setAct_memo("回复修改定单编号为" + temp);
        cal.setAct_me("");
        cal.setActionLog();
      }
      DynaSqlBean dybBean = new DynaSqlBean();
      dybBean.setSql(strsql);
      dybBean.executeBatch();
      // setFormbeen(form,request,selectwhere,uname);

      PropertyUtils.setSimpleProperty(form, "freeformstate", "0");

      PropertyUtils.setSimpleProperty(form, "message", "1");

      //			TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC8888888",
          l_end - l_begin);
      return (mapping.findForward("success"));

    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Database.formbean"));
      saveErrors(request, errors);
      //			TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "C",
          "LYC9999999",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
  }