public String saveOrUpdateAction() throws Exception {
    String id = request.getParameter("id");
    String jz = request.getParameter("jz");
    String bhmc = request.getParameter("bhmc");
    String strtysj = request.getParameter("tysj");
    String tyyy = request.getParameter("tyyy");
    String tyzxr = request.getParameter("tyzxr");
    String tyzby = request.getParameter("tyzby");
    String strjysj = request.getParameter("jysj");
    String jyyy = request.getParameter("jyyy");
    String jyzxr = request.getParameter("jyzxr");
    String jyzby = request.getParameter("jyzby");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");

    try {
      Dqsbbhjl dqsbbhjl = null;
      if (StringUtil.isNotEmpty(id)) {
        dqsbbhjl = dqsbbhjlManager.get(id);
      } else {
        dqsbbhjl = new Dqsbbhjl();
      }

      dqsbbhjl.setJz(jz);
      dqsbbhjl.setBhmc(bhmc);
      dqsbbhjl.setTyyy(tyyy);
      dqsbbhjl.setTyzxr(tyzxr);
      dqsbbhjl.setTyzby(tyzby);
      dqsbbhjl.setJyyy(jyyy);
      dqsbbhjl.setJyzxr(jyzxr);
      dqsbbhjl.setJyzby(jyzby);

      if (StringUtil.isNotEmpty(strtysj)) {
        Date tysj = sdf.parse(strtysj);
        dqsbbhjl.setTysj(tysj);
      }
      if (StringUtil.isNotEmpty(strjysj)) {
        Date jysj = sdf.parse(strjysj);
        dqsbbhjl.setJysj(jysj);
      }

      dqsbbhjlManager.save(dqsbbhjl);
    } catch (Exception e) {
      e.printStackTrace();
      outputJson("{success:false}");
    }
    outputJson("{success:true}");
    return NONE;
  }
Beispiel #2
0
  /**
   * 计算公式
   *
   * @param cf
   * @return
   * @throws Exception
   */
  public String eval(String cf) {
    if (StringUtil.isNotEmpty(cf)) {
      cf = StringUtil.decodeChars(cf, "@,>,<,+,-,?,(,), ,.,:,\",'");
    }

    cf = eval_VALUE(cf); // 1.匹配@VALUE公式
    cf = eval_CONTEXT(cf); // 1.匹配@CONTEXT公式
    cf = eval_PARSENUMBER(cf); // 2.匹配@PARSENUMBER();公式
    cf = eval_SYSDT(cf); // 3.匹配@SYSDT公式
    cf = eval_GROUPNAME(cf); // 4.匹配@GROUPNAME公式
    cf = eval_GROUPSHORTNAME(cf); // 5.匹配@GROUPSHORTNAME公式
    cf = eval_HTTPSESSION(cf); // 6.匹配@HTTPSESSION公式
    cf = eval_USERLOGINNAME(cf); // 7.匹配@USERLOGINNAME公式
    cf = eval_USERLOGINID(cf); // 8.匹配@USERLOGINID公式
    cf = eval_USERCNAME(cf); // 9.匹配@USERCNAME公式
    cf = eval_SQL(cf); // 10.匹配@SQL公式
    cf = eval_UUID(cf); // 11.匹配@UUID公式
    cf = eval_INVOKE(cf); // 11.匹配@UUID公式
    cf = eval_IF(cf); // 12.匹配@IF公式

    Interpreter i = new Interpreter();
    try {
      cf = i.eval(cf) + "";
    } catch (EvalError e) {
      e.printStackTrace();
      String msg = e.getMessage();
      msg = StringUtil.formatHTML(msg);
      return "%ERROR%";
    }
    return cf;
  }
  /** 描述 : 生成采购计划明细序号(2位) 作者 : caofei 时间 : Nov 4, 2010 参数 : 返回值 : String 异常 : */
  @SuppressWarnings({"unused", "unchecked"})
  public String getMaxXH(String cgjhbh) throws Exception {
    String retValue = "1";
    Connection conn = null;
    DataSource dataSource = (DataSource) SpringContextUtil.getBean("dataSource");

    try {
      conn = dataSource.getConnection();
      String sql = "select max(xh) from TB_WZ_YCGJHMX where CGJHBH = '" + cgjhbh + "'";
      Statement st = conn.createStatement();
      ResultSet rs = st.executeQuery(sql);
      if (rs.next()) {
        String maxBH = rs.getString(1);
        if (StringUtil.isNotEmpty(maxBH)) {
          int max = Integer.parseInt(maxBH) + 1;
          retValue = String.valueOf(max);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (conn != null) {
        try {
          conn.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return retValue;
  }
  /** 描述 : 生成采购计划编号(8位) 作者 : caofei 时间 : Nov 4, 2010 参数 : 返回值 : String 异常 : */
  @SuppressWarnings({"unused", "unchecked"})
  public String getMaxNum() throws Exception {
    String retValue = "00000001";
    Connection conn = null;
    DataSource dataSource = (DataSource) SpringContextUtil.getBean("dataSource");

    try {
      conn = dataSource.getConnection();
      String sql = "select max(bh) from TB_WZ_YCGJH";
      Statement st = conn.createStatement();
      ResultSet rs = st.executeQuery(sql);
      if (rs.next()) {
        String maxBH = rs.getString(1);
        if (StringUtil.isNotEmpty(maxBH)) {
          int max = Integer.parseInt(maxBH) + 1;
          NumberFormat nFormat = NumberFormat.getNumberInstance();
          nFormat.setMinimumIntegerDigits(8);
          retValue = nFormat.format(max).replaceAll(",", "");
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (conn != null) {
        try {
          conn.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return retValue;
  }
Beispiel #5
0
  /**
   * 将request中存在的param以及attribute全部存入context中
   *
   * @param request
   */
  public void initExpContext(HttpServletRequest request) {

    Enumeration<String> enumParams = request.getParameterNames();
    while (enumParams.hasMoreElements()) {
      String param = enumParams.nextElement();
      context.setVar(param, request.getParameter(param));
    }

    Enumeration<String> enumAttrs = request.getAttributeNames();
    while (enumAttrs.hasMoreElements()) {
      String attr = enumAttrs.nextElement();
      context.setVar(attr, request.getAttribute(attr));
    }

    String recordJson = (String) context.getVar("recordJson");
    if (StringUtil.isNotEmpty(recordJson)) {
      initContextVarFromJson(recordJson);
    }
  }