dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15313
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5495: Included GrandTotal in MDReport
------------------------------------------------------------
revno: 5495
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-20 11:51:32 +0530
message:
Included GrandTotal in MDReport
modified:
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java 2011-12-14 11:06:08 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java 2011-12-20 06:21:32 +0000
@@ -240,6 +240,34 @@
// collect dataElementIDs by commaSepareted
String dataElmentIdsByComma = reportService.getDataelementIds( reportDesignList );
+
+ /*
+ Map<String, String> tempAggDeMap = new HashMap<String, String>();
+
+ if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+ {
+ Iterator<OrganisationUnit> tempOrgUnit = orgUnitList.iterator();
+ while ( tempOrgUnit.hasNext() )
+ {
+ OrganisationUnit orgUnit = (OrganisationUnit) tempOrgUnit.next();
+
+ List<OrganisationUnit> tempOrgUnitWithChildTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnit.getId() ) );
+ tempOrgUnitWithChildTree.retainAll( orgUnitGroupMemberList );
+
+ Iterator<OrganisationUnit> tempCurrIt = tempOrgUnitWithChildTree.iterator();
+ while ( tempCurrIt.hasNext() )
+ {
+ OrganisationUnit tempCurrentOrgUnit = (OrganisationUnit) tempCurrIt.next();
+
+ List<OrganisationUnit> childOrgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( tempCurrentOrgUnit.getId() ) );
+ List<Integer> tempchildOrgUnitTreeIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, childOrgUnitTree ) );
+ String tempchildOrgUnitsByComma = getCommaDelimitedString( tempchildOrgUnitTreeIds );
+
+ tempAggDeMap.putAll( reportService.getAggDataFromDataValueTable( tempchildOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+ }
+ }
+ }
+ */
System.out.println( selOrgUnit.getName()+ " : " + selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
int orgUnitCount = 0;
@@ -252,6 +280,7 @@
int rowInc = 0;
int slno = 1;
+ Double[] grandTotal = new Double[ reportDesignList.size() ];
Iterator<OrganisationUnit> it = orgUnitList.iterator();
while ( it.hasNext() )
@@ -295,6 +324,7 @@
{
OrganisationUnit currentOrgUnit = (OrganisationUnit) currIt.next();
+ //12/12/2011
Map<String, String> tempAggDeMap = new HashMap<String, String>();
if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
{
@@ -304,6 +334,7 @@
tempAggDeMap.putAll( reportService.getAggDataFromDataValueTable( tempchildOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
}
+ //12/12/2011
sheet0.addCell( new Number( colStart, rowStart+rowInc, slno, getCellFormat1() ) );
sheet0.addCell( new Label( colStart+1, rowStart+rowInc, tempOrgUnit.getName(), getCellFormat1() ) );
sheet0.addCell( new Label( colStart+2, rowStart+rowInc, currentOrgUnit.getName(), getCellFormat1() ) );
@@ -353,6 +384,15 @@
}
tempSubTotal += tempAggValue;
+ if( grandTotal[deCount] != null )
+ {
+ grandTotal[deCount] += tempAggValue;
+ }
+ else
+ {
+ grandTotal[deCount] = tempAggValue;
+ }
+
Double tempST = subTotalMap.get( deCount );
if( tempST != null )
{
@@ -381,6 +421,15 @@
tempAggValue = 0.0;
}
tempSubTotal += tempAggValue;
+ if( grandTotal[deCount] != null )
+ {
+ grandTotal[deCount] += tempAggValue;
+ }
+ else
+ {
+ grandTotal[deCount] = tempAggValue;
+ }
+
Double tempST = subTotalMap.get( deCount );
if( tempST != null )
{
@@ -407,6 +456,15 @@
tempAggValue = 0.0;
}
tempSubTotal += tempAggValue;
+ if( grandTotal[deCount] != null )
+ {
+ grandTotal[deCount] += tempAggValue;
+ }
+ else
+ {
+ grandTotal[deCount] = tempAggValue;
+ }
+
Double tempST = subTotalMap.get( deCount );
if( tempST != null )
{
@@ -456,7 +514,7 @@
{
try
{
- sheet0.addCell( new Number( tempColNo, tempRowNo, Integer.parseInt( tempStr ), getCellFormat1() ) );
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), getCellFormat1() ) );
}
catch ( Exception e )
{
@@ -473,15 +531,30 @@
{
sheet0.addCell( new Label( tempColNo, tempRowNo, " ", getCellFormat2() ) );
}
- //tempOrgUnitCount++;
- //rowInc++;
+
+ if( orgUnitCount == orgUnitList.size()-1 )
+ {
+ tempRowNo++;
+ sheet0.addCell( new Label( colStart, tempRowNo, " ", getCellFormat2() ) );
+ sheet0.addCell( new Label( colStart+1, tempRowNo, " ", getCellFormat2() ) );
+ sheet0.addCell( new Label( colStart+2, tempRowNo, "GRAND TOTAL", getCellFormat2() ) );
+
+ try
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, grandTotal[deCount] , getCellFormat2() ) );
+ }
+ catch ( Exception e )
+ {
+ sheet0.addCell( new Label( tempColNo, tempRowNo, " ", getCellFormat2() ) );
+ }
+ }
}
}
else
{
try
{
- sheet0.addCell( new Number( tempColNo, tempRowNo, Integer.parseInt( tempStr ), getCellFormat1() ) );
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), getCellFormat1() ) );
}
catch ( Exception e )
{
@@ -677,4 +750,6 @@
throw new RuntimeException( "Illegal DataElement id", ex );
}
}
+
+
}