IDEMPIERE-812 Improve statistics for reports

This commit is contained in:
Carlos Ruiz 2013-03-28 20:03:57 -05:00
parent 6956b186a9
commit 5a5712fb71
5 changed files with 59 additions and 6 deletions

View File

@ -42,7 +42,7 @@ public class ProcessInfo implements Serializable
/** /**
* *
*/ */
private static final long serialVersionUID = 1426147857271483561L; private static final long serialVersionUID = 1371812474929601477L;
/** /**
* Constructor * Constructor
@ -137,6 +137,9 @@ public class ProcessInfo implements Serializable
/** Export File */ /** Export File */
private File m_exportFile = null; private File m_exportFile = null;
/** Row count */
private int m_rowCount;
/** /**
* String representation * String representation
* @return String representation * @return String representation
@ -761,4 +764,13 @@ public class ProcessInfo implements Serializable
{ {
m_Record_IDs = Record_IDs; m_Record_IDs = Record_IDs;
} }
public void setRowCount(int rowCount) {
m_rowCount = rowCount;
}
public int getRowCount() {
return m_rowCount;
}
} // ProcessInfo } // ProcessInfo

View File

@ -53,8 +53,8 @@ import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JRParameter; import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRPropertiesUtil; import net.sf.jasperreports.engine.JRPropertiesUtil;
import net.sf.jasperreports.engine.JRQuery; import net.sf.jasperreports.engine.JRQuery;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignQuery; import net.sf.jasperreports.engine.design.JRDesignQuery;
@ -67,6 +67,8 @@ import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.engine.export.JRTextExporter; import net.sf.jasperreports.engine.export.JRTextExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter; import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXmlExporter; import net.sf.jasperreports.engine.export.JRXmlExporter;
import net.sf.jasperreports.engine.fill.JRBaseFiller;
import net.sf.jasperreports.engine.fill.JRFiller;
import net.sf.jasperreports.engine.fill.JRSwapFileVirtualizer; import net.sf.jasperreports.engine.fill.JRSwapFileVirtualizer;
import net.sf.jasperreports.engine.util.JRLoader; import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRSwapFile; import net.sf.jasperreports.engine.util.JRSwapFile;
@ -351,6 +353,8 @@ public class ReportStarter implements ProcessCall, ClientProcess
private boolean startProcess0(Properties ctx, ProcessInfo pi, Trx trx) private boolean startProcess0(Properties ctx, ProcessInfo pi, Trx trx)
{ {
processInfo = pi; processInfo = pi;
int nrows = 0;
Object onrows = null;
String Name=pi.getTitle(); String Name=pi.getTitle();
int AD_PInstance_ID=pi.getAD_PInstance_ID(); int AD_PInstance_ID=pi.getAD_PInstance_ID();
int Record_ID=pi.getRecord_ID(); int Record_ID=pi.getRecord_ID();
@ -603,7 +607,9 @@ public class ReportStarter implements ProcessCall, ClientProcess
params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
DefaultJasperReportsContext jasperContext = DefaultJasperReportsContext.getInstance(); DefaultJasperReportsContext jasperContext = DefaultJasperReportsContext.getInstance();
JRPropertiesUtil.getInstance(jasperContext).setProperty("net.sf.jasperreports.awt.ignore.missing.font", "true"); JRPropertiesUtil.getInstance(jasperContext).setProperty("net.sf.jasperreports.awt.ignore.missing.font", "true");
JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, params, conn); JRBaseFiller filler = JRFiller.createFiller(jasperContext, jasperReport);
JasperPrint jasperPrint = filler.fill(params, conn);
onrows = filler.getVariableValue(JRVariable.REPORT_COUNT);
if (!processInfo.isExport()) if (!processInfo.isExport())
{ {
@ -734,6 +740,10 @@ public class ReportStarter implements ProcessCall, ClientProcess
} }
} }
if (onrows != null && onrows instanceof Integer) {
nrows = (Integer) onrows;
processInfo.setRowCount(nrows);
}
reportResult( AD_PInstance_ID, null, trxName); reportResult( AD_PInstance_ID, null, trxName);
return true; return true;
} }

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ import org.adempiere.util.IProcessUI;
import org.adempiere.util.ProcessUtil; import org.adempiere.util.ProcessUtil;
import org.compiere.db.CConnection; import org.compiere.db.CConnection;
import org.compiere.interfaces.Server; import org.compiere.interfaces.Server;
import org.compiere.model.MPInstance;
import org.compiere.model.MRule; import org.compiere.model.MRule;
import org.compiere.print.ReportCtl; import org.compiere.print.ReportCtl;
import org.compiere.process.ClientProcess; import org.compiere.process.ClientProcess;
@ -37,6 +38,7 @@ import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.util.Util;
import org.compiere.wf.MWFProcess; import org.compiere.wf.MWFProcess;
/** /**
@ -268,6 +270,14 @@ public abstract class AbstractProcessCtl implements Runnable
m_pi.setReportingProcess(true); m_pi.setReportingProcess(true);
m_pi.setClassName(ProcessUtil.JASPER_STARTER_CLASS); m_pi.setClassName(ProcessUtil.JASPER_STARTER_CLASS);
startProcess(); startProcess();
MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null);
String errmsg = pinstance.getErrorMsg();
if (Util.isEmpty(errmsg, true))
errmsg = "Rows=" + String.valueOf(m_pi.getRowCount());
else
errmsg += " Rows=" + m_pi.getRowCount();
pinstance.setErrorMsg(errmsg);
pinstance.saveEx();
unlock(); unlock();
return; return;
} }
@ -278,6 +288,14 @@ public abstract class AbstractProcessCtl implements Runnable
// Start Report ----------------------------------------------- // Start Report -----------------------------------------------
boolean ok = ReportCtl.start(m_processUI, windowno, m_pi, IsDirectPrint); boolean ok = ReportCtl.start(m_processUI, windowno, m_pi, IsDirectPrint);
m_pi.setSummary("Report", !ok); m_pi.setSummary("Report", !ok);
MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null);
String errmsg = pinstance.getErrorMsg();
if (Util.isEmpty(errmsg, true))
errmsg = "Rows=" + String.valueOf(m_pi.getRowCount());
else
errmsg += " Rows=" + m_pi.getRowCount();
pinstance.setErrorMsg(errmsg);
pinstance.saveEx();
unlock (); unlock ();
} }
/********************************************************************** /**********************************************************************

View File

@ -16,6 +16,16 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.print; package org.compiere.print;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_DUNNING;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_INVOICE;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_ORDER;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_PAYMENT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_PROJECT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_C_RFQRESPONSE;
import static org.compiere.model.SystemIDs.PROCESS_RPT_FINREPORT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_FINSTATEMENT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INOUT;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -27,7 +37,6 @@ import org.compiere.model.MProcess;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PrintInfo; import org.compiere.model.PrintInfo;
import static org.compiere.model.SystemIDs.*;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -66,6 +75,7 @@ public class ReportCtl
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (ReportCtl.class); private static CLogger s_log = CLogger.getCLogger (ReportCtl.class);
private volatile static ProcessInfo m_pi;
/** /**
* Create Report. * Create Report.
@ -113,6 +123,7 @@ public class ReportCtl
{ {
if (s_log.isLoggable(Level.INFO)) s_log.info("start - " + pi); if (s_log.isLoggable(Level.INFO)) s_log.info("start - " + pi);
m_pi = pi;
/** /**
* Order Print * Order Print
*/ */
@ -363,6 +374,8 @@ public class ReportCtl
private static void createOutput(ReportEngine re, boolean printPreview, String printerName) private static void createOutput(ReportEngine re, boolean printPreview, String printerName)
{ {
if (m_pi != null)
m_pi.setRowCount(re.getPrintData().getRowCount());
if (printPreview) if (printPreview)
preview(re); preview(re);
else { else {