/** * 计算公式 * * @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; }
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; }
/** 描述 : 生成采购计划明细序号(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; }
/** * 记录一条日志【登陆,逻辑,异常】 * * @param logText * @param classStr * @param exceptions * @author 朱启亮 * @date 2008-1-31 */ public void saveLog(JoinPoint jp, String logText, String classStr, Exception... exceptions) { Object obj = jp.getThis(); String ip = "unknow"; if (obj instanceof AbstractAction) { AbstractAction action = (AbstractAction) obj; HttpServletRequest request = action.getRequest(); ip = this.getIpAddr(request); } HttpSession session = (HttpSession) UserSession.get(Constants.THREADLOCAL_CURRENT_SESSION); Serializable personid = (Serializable) session.getAttribute(Constants.SESSION_CURRENT_PERSONID); Person person = null; // 区分游客,root用户,普通用户 if (personid == null) { person = new Person(); person.setUserName(Constants.GUEST_NAME); person.setId(Constants.GUEST_ID); person.setUserLoginName(Constants.GUEST_NAME); } else if (personid.equals(Constants.ADMINISTRATOR_ID)) { person = new Person(); person.setUserName(Constants.ADMINISTRATOR_NAME); person.setId(Constants.ADMINISTRATOR_ID); person.setUserLoginName(Constants.ADMINISTRATOR_ACCOUNT); } else { PersonManager personManager = this.getPersonManager(); person = personManager.get(personid); } StringUtil.isoToUTF8(logText); Log log = new Log(); log.setIp(ip); log.setLog(logText); log.setDt(new Date()); // 记录日志的类型 if (exceptions.length == 0) { // if(classStr.equals(Constants.LOGINACTION)){ // log.setType(Log.LOG_TYPE_LOGIN); // }else{ log.setType(Log.LOG_TYPE_LOGIC); // } } else { log.setType(Log.LOG_TYPE_EXCEPTION); } log.setPersonName(person.getUserName()); if (person.getUserName().equals(Constants.GUEST_NAME) || person.getUserName().equals(Constants.ADMINISTRATOR_NAME)) { log.setPersonLoginName(person.getUserLoginName()); } else { log.setPersonLoginName(person.getUserLoginName()); } logManager.save(log); }
/** * 将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); } }