public String getFilterConditionExpression( ReportRequest rrequest, ReportBean rbean, ReportDataSetValueBean datasetbean) { AbsListReportFilterBean filterBean = rrequest.getCdb(rbean.getId()).getFilteredBean(); if (filterBean == null) return null; ColBean cbTmp = (ColBean) filterBean.getOwner(); if (!cbTmp.isMatchDataSet(datasetbean)) return null; String filterval = rrequest.getStringAttribute(filterBean.getId(), ""); if (filterval.equals("")) return null; if (cbTmp.getDatatypeObj() == null || cbTmp.getDatatypeObj() instanceof VarcharType || cbTmp.getDatatypeObj() instanceof AbsDateTimeType) { filterval = Tools.replaceAll(filterval, ";;", "','"); if (!filterval.startsWith("'")) filterval = "'" + filterval; if (filterval.endsWith("','")) filterval = filterval.substring(0, filterval.length() - 3); if (!filterval.endsWith("'")) filterval = filterval + "'"; if (filterval.equals("'")) filterval = ""; } else { filterval = Tools.replaceAll(filterval, ";;", ","); if (filterval.endsWith(",")) filterval = filterval.substring(0, filterval.length() - 1); } String where = null; String column = null; if (filterBean.getFilterColumnExpression() != null && !filterBean.getFilterColumnExpression().trim().equals("")) { column = filterBean.getFilterColumnExpression(); } else { column = cbTmp.getColumn(); } if (!filterval.trim().equals("")) { where = " where " + column + " in (" + filterval + ") "; } return where; }
private void initDisplayComponentObj() { if (this.componentid == null || this.componentid.trim().equals("") || this.componentid.equals( this.ownerComponentObj.getConfigBean().getId())) { // 如果指定的是显示本组件的相应部分 this.displayComponentObj = this.ownerComponentObj; return; } IComponentType componentObj = rrequest.getComponentTypeObj(this.componentid.trim(), null, false); if (componentObj == null) { throw new WabacusRuntimeException( "页面" + rrequest.getPagebean().getId() + "下不存在id为" + componentid + "的组件"); } this.displayComponentObj = (AbsComponentType) componentObj; if (rrequest.getShowtype() == Consts.DISPLAY_ON_PAGE) { if (this.displayComponentObj instanceof AbsReportType) { ReportBean rbDisplay = (ReportBean) this.displayComponentObj.getConfigBean(); if (rbDisplay.isSlaveReportDependsonListReport()) { throw new WabacusRuntimeException( rbDisplay.getPath() + "是从报表,不能在id为" + this.ownerComponentObj.getConfigBean().getPath() + "的组件的动态模板中显示它的内容"); } } if (this.ownerComponentObj instanceof AbsReportType) { ReportBean rbOwner = (ReportBean) this.ownerComponentObj.getConfigBean(); if (rbOwner.isSlaveReportDependsonListReport()) { throw new WabacusRuntimeException(rbOwner.getPath() + "是从报表,不能其动态模板中显示其它组件的内容"); } } } }
public String createColumnFilter(ReportRequest rrequest, AbsListReportColBean alrcbean) { ReportBean rbean = alrcbean.getOwner().getReportBean(); StringBuffer resultBuf = new StringBuffer(); AbsListReportFilterBean filterbean = alrcbean.getFilterBean(); StringBuffer paramsBuf = new StringBuffer(); paramsBuf.append("{reportguid:\"").append(rbean.getGuid()).append("\""); paramsBuf .append(",property:\"") .append(((ColBean) alrcbean.getOwner()).getProperty()) .append("\""); paramsBuf.append(",webroot:\"").append(Config.webroot).append("\""); paramsBuf.append(",skin:\"").append(rrequest.getPageskin()).append("\""); CacheDataBean cdb = rrequest.getCdb(rbean.getId()); String imgurl = "/webresources/skin/" + rrequest.getPageskin() + "/images/"; paramsBuf.append(",urlParamName:\""); if (filterbean.isConditionRelate()) { paramsBuf.append(filterbean.getConditionname()).append("\""); paramsBuf.append(",multiply:\"false\""); String filtervalue = rrequest.getStringAttribute(filterbean.getConditionname(), ""); if (!filtervalue.equals("")) { imgurl = imgurl + "filter2.jpg"; } else { imgurl = imgurl + "filter1.jpg"; } } else { paramsBuf.append(filterbean.getId()).append("\""); paramsBuf.append(",multiply:\"true\""); String filtervalue = rrequest.getStringAttribute(filterbean.getId(), ""); if (cdb.getFilteredBean() == null || filtervalue.trim().equals("") || !filterbean.equals(cdb.getFilteredBean())) { imgurl = imgurl + "filter1.jpg"; } else { imgurl = imgurl + "filter2.jpg"; } } imgurl = Tools.replaceAll(Config.webroot + imgurl, "//", "/"); // 过滤图片路径 paramsBuf.append(",filterwidth:").append(filterbean.getFilterwidth()); paramsBuf.append(",filtermaxheight:").append(filterbean.getFiltermaxheight()); paramsBuf.append("}"); resultBuf .append("<SPAN class=\"filter_span\"><input type=\"button\" id=\"") .append(rbean.getGuid() + alrcbean.hashCode()) .append("\""); resultBuf.append( " onmouseout=\"try{drag_enabled=true;}catch(e){}\" onmouseover=\"try{drag_enabled=false;this.style.cursor='pointer';}catch(e){}\""); resultBuf .append( " style=\"width:16px;height:17px;background-color:transparent;border:0; background-image: url(") .append(imgurl + ");\""); resultBuf .append(" onclick=\"try{getFilterDataList(this,'") .append(Tools.jsParamEncode(paramsBuf.toString())) .append("');return false;}catch(e){logErrorsAsJsFileLoad(e);}\""); resultBuf.append("/></SPAN>"); return resultBuf.toString(); }
public int doEndTag() throws JspException { try { int flag = doMyEndTag(); rrequest.getWResponse().setJspout(null); return flag; } catch (Exception e) { log.error("显示页面" + rrequest.getPagebean().getId() + "失败", e); rrequest.getWResponse().getMessageCollector().error("显示页面失败", null, true); return EVAL_PAGE; } }
public int getFixedcols(ReportRequest rrequest) { if (rrequest == null) return fixedcols; Object objVal = rrequest.getAttribute(this.getOwner().getReportBean().getId(), "DYNAMIC_FIXED_COLSCOUNT"); if (objVal == null) return fixedcols; return ((Integer) objVal).intValue(); }
public void storeRoworder(ReportRequest rrequest, ReportBean rbean) { String rowordertype = rrequest.getStringAttribute(rbean.getId() + "_ROWORDERTYPE", ""); if (rowordertype.equals("") || !Consts.lstAllRoworderTypes.contains(rowordertype)) return; String roworderparams = rrequest.getStringAttribute(rbean.getId() + "_ROWORDERPARAMS", ""); if (roworderparams.equals("")) return; AbsListReportBean alrbean = (AbsListReportBean) rbean.getExtendConfigDataForReportType(AbsListReportType.KEY); IListReportRoworderPersistence lsObj = alrbean.getLoadStoreRoworderObject(); // 获取到读写行排序顺序值的类对象 if (lsObj == null) lsObj = Config.default_roworder_object; List<Map<String, String>> lstColValusInAllRows = EditableReportAssistant.getInstance().parseSaveDataStringToList(roworderparams); if (lstColValusInAllRows.size() == 0) return; Map<String, String> mColValuesInRow = lstColValusInAllRows.get(0); log.debug("被排序记录行参数:" + mColValuesInRow); if (rowordertype.equals(Consts.ROWORDER_INPUTBOX)) { String newrowordervalue = rrequest.getStringAttribute(rbean.getId() + "_ROWORDERVALUE", ""); lsObj.storeRoworderByInputbox(rrequest, rbean, mColValuesInRow, newrowordervalue); } else if (rowordertype.equals(Consts.ROWORDER_TOP)) { lsObj.storeRoworderByTop(rrequest, rbean, mColValuesInRow); } else { String direct = rrequest.getStringAttribute(rbean.getId() + "_ROWORDERDIRECT", ""); String destrowParams = rrequest.getStringAttribute(rbean.getId() + "_DESTROWPARAMS", ""); Map<String, String> mColValuesInDestRow = null; if (!destrowParams.trim().equals("")) { mColValuesInDestRow = EditableReportAssistant.getInstance().parseSaveDataStringToList(destrowParams).get(0); log.debug("目标位置记录行参数:" + mColValuesInDestRow); } if (rowordertype.equals(Consts.ROWORDER_DRAG)) { lsObj.storeRoworderByDrag( rrequest, rbean, mColValuesInRow, mColValuesInDestRow, direct.toLowerCase().trim().equals("true")); } else { lsObj.storeRoworderByArrow( rrequest, rbean, mColValuesInRow, mColValuesInDestRow, direct.toLowerCase().trim().equals("true")); } } }
public void setFixedcols(ReportRequest rrequest, int fixedcols) { if (rrequest == null) { this.fixedcols = fixedcols; } else { // 是运行时设置fixedcols(目前只有交叉动态列报表是这种情况,在运行时计算固定列) rrequest.setAttribute( this.getOwner().getReportBean().getId(), "DYNAMIC_FIXED_COLSCOUNT", fixedcols); } }
public void doEnd(ReportRequest rrequest) { Date operateTime1 = new Date(); java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String operateTime = format1.format(operateTime1); String userid = rrequest.getRequest().getSession().getAttribute("userId").toString(); String remoteAddr = rrequest.getRequest().getSession().getAttribute("remoteAddr").toString(); String logintime = rrequest.getRequest().getSession().getAttribute("loginTime").toString(); // String opt= rrequest.getRequest().getAttribute("operateTime").toString(); String menuName = rrequest.getPagebean().getId(); // String pageid=rrequest.getPagebean().getId(); // System.out.println(menuName); // System.out.println(pageid); /*if(menuName.equalsIgnoreCase("eventType")){ menuName="事件类型管理"; } else{ System.out.println("没执行if语句"); }*/ final Connection conn = Config.getInstance().getDataSource("").getConnection(); PreparedStatement pstmt = null; try { String sql = "insert into LogInfo(UserId,LoginTime,MenuName,OperateTime,UserIp) values(?,?,?,?,?)"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, userid); pstmt.setString(2, logintime); pstmt.setString(3, menuName); pstmt.setString(4, operateTime); pstmt.setString(5, remoteAddr); pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { pstmt.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public int doStartTag() throws JspException { initTagState(); request = (HttpServletRequest) pageContext.getRequest(); out = pageContext.getOut(); rrequest = (ReportRequest) request.getAttribute("WX_REPORTREQUEST"); this.ownerComponentObj = (AbsReportType) request.getAttribute("WX_COMPONENT_OBJ"); rrequest.getWResponse().setJspout(this.out); if (isRootTag()) { if (rrequest == null) throw new JspException("没有取到ReportRequest对象,无法显示报表"); if (this.ownerComponentObj == null) throw new JspException("没有取到组件对象,无法显示组件"); } initDisplayComponentObj(); try { return doMyStartTag(); } catch (Exception e) { log.error("显示页面" + rrequest.getPagebean().getId() + "失败", e); rrequest.getWResponse().getMessageCollector().error("显示页面失败", null, true); return SKIP_BODY; } }
public String getColLabelWithOrderBy(ColBean cbean, ReportRequest rrequest, String dynlabel) { String ordercolumn = cbean.getColumn(); String label = rrequest.getI18NStringValue(dynlabel); label = label == null ? "" : label.trim(); if (rrequest.getShowtype() != Consts.DISPLAY_ON_PAGE) return label; if (ordercolumn == null || ordercolumn.trim().equals("")) return label; String[] orderbys = (String[]) rrequest.getAttribute(cbean.getReportBean().getId(), "ORDERBYARRAY"); String arrow = ""; String order = "asc"; if (orderbys != null && orderbys.length == 2) { if (orderbys[0].equalsIgnoreCase(ordercolumn)) { arrow = " <img src='" + Config.webroot + "/webresources/skin/" + rrequest.getPageskin() + "/images/"; if (orderbys[1] == null || orderbys[1].equalsIgnoreCase("desc")) { arrow = arrow + "desc.gif'>"; order = "asc"; } else { arrow = arrow + "asc.gif'>"; order = "desc"; } } } arrow = Tools.replaceAll(arrow, "//", "/"); StringBuffer resultBuf = new StringBuffer(); resultBuf.append("<span onmouseover=\"this.style.cursor='pointer';\" onclick=\""); resultBuf .append("try{clickorderby(this,'") .append(ordercolumn) .append("||") .append(order) .append("');}catch(e){logErrorsAsJsFileLoad(e);}\">"); resultBuf.append(label).append(arrow); resultBuf.append("</span>"); return resultBuf.toString(); }
public void beforeDisplayReportDataPerRow( ReportRequest rrequest, ReportBean rbean, RowDataBean rowDataBean) { if (rowDataBean.getRowindex() < 0) { // 当前正在显示标题部分 /** 下面在数据标题行前面插入一行动态的标题行 */ String insertedHtml = "<tr><td colspan='" + rowDataBean.getColspans() + "' align='center' bgcolor='#dddddd'><font size='3'><b>动态插入的报表标题行</b></font></td></tr>"; rowDataBean.setInsertDisplayRowHtml(insertedHtml); } else if (rowDataBean.getRowindex() == Integer.MAX_VALUE) { // 当前是显示完最后一行记录后的调用 String insertedHtml = "<tr>"; for (int i = 0; i < rowDataBean.getColspans(); i++) { System.out.println(i + "|||" + ((ColBean) rowDataBean.getLstColBeans().get(i))); insertedHtml += "<td align='center' bgcolor='#dddddd'><font size='3'><b>" + ((ColBean) rowDataBean.getLstColBeans().get(i)).getLabel(rrequest) + "</b></font></td>"; } insertedHtml += "</tr>"; rowDataBean.setInsertDisplayRowHtml(insertedHtml); } else { // 显示数据行 AbsReportType reportTypeObj = rrequest.getDisplayReportTypeObj(rbean.getId()); List<AbsReportDataPojo> lstData = reportTypeObj.getLstReportData(); // 所有报表数据的容器 if (lstData.size() > 0) { // 报表有数据 Object dataObj = lstData.get(rowDataBean.getRowindex()); // 取到即将显示记录的数据对象 String currentSex = (String) rowDataBean.getColData("sex"); // 取到当前记录的性别列 currentSex = currentSex == null ? "" : currentSex.trim(); String displayedsex = reportTypeObj.getReportRequest().getStringAttribute("DISPLAYED_SEX"); // 上一条记录显示的性别 if (displayedsex == null || !displayedsex.equals( currentSex)) { // 如果还没有显示记录,或者当前正要显示的记录的性别和上一条不是同一个性别,则说明开始显示新的性别的记录(这是因为查询报表的SQL语句中已经按性别排了序) reportTypeObj .getReportRequest() .setAttribute("DISPLAYED_SEX", currentSex); // 存下当前记录显示的性别,以便后面显示其它记录时比较 int[] tmp = getRecordCntAndTotalAges(reportTypeObj, lstData, currentSex); float avgage = 0; if (tmp[0] > 0) avgage = tmp[1] / tmp[0]; StringBuffer insertedHtmlBuf = new StringBuffer(); insertedHtmlBuf.append( "<tr><td colspan='" + rowDataBean.getColspans() + "' align='center' bgcolor='#eeeeee'>"); insertedHtmlBuf.append("<font size='3'><b>" + currentSex + "性员工列表</b></font>"); insertedHtmlBuf.append(" 【记录数:" + tmp[0] + ";平均年龄" + avgage + "】"); insertedHtmlBuf.append("</td></tr>"); rowDataBean.setInsertDisplayRowHtml(insertedHtmlBuf.toString()); } } } }
/** 当报表没有配置PDF模板时,此方法在显示完每页PDF后执行 现在在此方法中演示显示完每页后向其中添加一个图片 */ public void afterDisplayPdfPageWithoutTemplate(Document document, AbsReportType reportTypeObj) { super.afterDisplayPdfPageWithoutTemplate(document, reportTypeObj); ReportRequest rrequest = reportTypeObj.getReportRequest(); String serverName = rrequest.getRequest().getServerName(); String serverPort = String.valueOf(rrequest.getRequest().getServerPort()); String imgurl = "http://" + serverName + ":" + serverPort + Config.webroot + "wabacusdemo/pdftemplate/logo.gif"; // 构造要添加图片的URL try { Image img = Image.getInstance(imgurl); float width = document.getPageSize().getWidth(); float height = document.getPageSize().getHeight(); // width = width - img.getWidth(); img.setAbsolutePosition(width / 2, height / 2 + 300f); img.setAlignment(Image.ALIGN_CENTER); document.add(img); } catch (Exception e) { e.printStackTrace(); } }
public String getDisplayValue(ReportRequest rrequest, AbsComponentType ownerComponentObj) { String ref = null; String popupparams = null; String dataimportinitsize = null; String asyn = null; String interceptor = null; if (this.mTagAttributes != null) { ref = this.mTagAttributes.get("ref"); popupparams = this.mTagAttributes.get("popupparams"); dataimportinitsize = this.mTagAttributes.get("dataimportinitsize"); asyn = this.mTagAttributes.get("asyn"); interceptor = this.mTagAttributes.get("interceptor"); } return TagAssistant.getInstance() .getDataImportDisplayValue( ref, asyn, popupparams, dataimportinitsize, this.tagContent, interceptor, rrequest.getRequest()); }
protected Object doGetResultSet( SPDataSetValueBean spBean, Object typeObj, StringBuffer systemParamsBuf) { log.debug(systemParamsBuf.toString()); String procedure = spBean.getProcedure(); if (rbean.getInterceptor() != null) { Object obj = rbean.getInterceptor().beforeLoadData(rrequest, rbean, typeObj, procedure); if (!(obj instanceof String)) { return obj; } procedure = (String) obj; } if (Config.show_sql) log.info("Execute sql: " + procedure); CallableStatement cstmt = null; try { cstmt = rrequest .getConnection(spBean.getOwnerSpProvider().getDatasource()) .prepareCall(procedure); AbsDatabaseType dbtype = rrequest.getDbType(spBean.getOwnerSpProvider().getDatasource()); VarcharType varcharObj = (VarcharType) Config.getInstance().getDataTypeByClass(VarcharType.class); int idx = 1; if (spBean.getLstStoreProcedureParams() != null && spBean.getLstStoreProcedureParams().size() > 0) { for (String paramTmp : spBean.getLstStoreProcedureParams()) { if (WabacusAssistant.getInstance() .isGetRequestContextValue(paramTmp)) { // 从request/session中取值 varcharObj.setPreparedStatementValue( idx, WabacusAssistant.getInstance().getRequestContextStringValue(rrequest, paramTmp, ""), cstmt, dbtype); } else if (Tools.isDefineKey("condition", paramTmp)) { setConditionValue( rrequest, spBean, cstmt, dbtype, idx, Tools.getRealKeyByDefine("condition", paramTmp), varcharObj); } else { varcharObj.setPreparedStatementValue(idx, paramTmp, cstmt, dbtype); } idx++; } } if (spBean.getOwnerSpProvider().isUseSystemParams()) { if (systemParamsBuf == null) systemParamsBuf = new StringBuffer(); cstmt.setString(idx++, systemParamsBuf.toString()); // 如果是查询报表数据,将系统参数传入 } if (dbtype instanceof Oracle) { cstmt.registerOutParameter(idx, OracleTypes.CURSOR); } rrequest.addUsedStatement(cstmt); cstmt.executeQuery(); ResultSet rs = null; if (dbtype instanceof Oracle) { rs = (ResultSet) cstmt.getObject(idx); } else { rs = cstmt.getResultSet(); } return rs; } catch (SQLException e) { throw new WabacusRuntimeException( "从数据库取报表" + rbean.getPath() + "数据时执行SQL:" + procedure + "失败", e); } }
protected void println(String content) { rrequest.getWResponse().println(content); }
public List<Map<String, String>> getLstSelectBoxOptions( ReportRequest rrequest, Map<String, String> mParentInputboxValues) { List<Map<String, String>> lstResults = new ArrayList<Map<String, String>>(); HttpServletRequest r = rrequest.getRequest(); String xianhao = r.getParameter("suoshuxianhao"); System.out.println( r.getParameter("suoshuxianhao") + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); List<String> conditions = new ArrayList<String>(); conditions.add("SUOSHUXIANHAO"); List<String> values = new ArrayList<String>(); values.add(xianhao); List<Map<String, String>> result = Dao.getInstance().getRecoed("ZBGL_ZBJBXX_XIANHAO_STBZ", conditions, values); Map<String, String> mOptionTmp = null; // Boolean empty=false; for (Map<String, String> m : result) { mOptionTmp = new HashMap<String, String>(); mOptionTmp.put("label", m.get("SHEBEIMING")); mOptionTmp.put("value", m.get("SHEBEIMING")); lstResults.add(mOptionTmp); } // System.out.println("m") if (lstResults.isEmpty()) { mOptionTmp = new HashMap<String, String>(); mOptionTmp.put("label", "暂无设备!"); lstResults.add(mOptionTmp); } System.out.println(lstResults); return lstResults; // 依赖的父输入框没有选中数据,则本子选择框也不显示选项 /* String sql="select distinct city from tbl_area where province like '%%'"; try { Connection conn=rrequest.getConnection(); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery(sql); Map<String,String> mOptionTmp=null; while(rs.next()) { mOptionTmp=new HashMap<String,String>(); mOptionTmp.put("label",rs.getString("city")); mOptionTmp.put("value",rs.getString("city")); lstResults.add(mOptionTmp); } rs.close(); stmt.close(); }catch(SQLException e) { e.printStackTrace(); return new ArrayList<Map<String,String>>(); } return lstResults; */ }
public void initUrl(IComponentConfigBean applicationConfigBean, ReportRequest rrequest) { rrequest.addParamToUrl("CSS", "rrequest{CSS}", false); rrequest.addParamToUrl("JS", "rrequest{JS}", false); super.initUrl(applicationConfigBean, rrequest); }
public ColBean getClickOrderByCbean(ReportRequest rrequest, ReportBean rbean) { String[] orderbys = (String[]) rrequest.getAttribute(rbean.getId(), "ORDERBYARRAY"); if (orderbys == null || orderbys.length != 2) return null; return rbean.getDbean().getColBeanByColColumn(orderbys[0]); }