Changeset 536 for trunk/grails-app/services
- Timestamp:
- May 18, 2010, 7:23:46 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskReportService.groovy
r535 r536 49 49 result.taskCount = result.taskList.size() 50 50 51 // Counts51 // Assets on Tasks Count. 52 52 result.totalAssetsOnTasksCount = 0 53 53 result.immediateCalloutCount = 0 … … 80 80 } // each() task 81 81 82 // Percentage s82 // Percentage of counts. 83 83 result.immediateCalloutPercentage = 0 84 84 result.totalPreventativePercentage = 0 … … 93 93 } 94 94 catch(ArithmeticException e) { 95 log.error "Could not calculate percentages: "+e 95 log.error "Could not calculate: Assets on Tasks Percentages: "+e 96 } 97 98 // Work Done. 99 result.immediateCalloutWorkDone = [total:0, hours:0, minutes:0, percentage:0] 100 result.unscheduledBreakinWorkDone = [total:0, hours:0, minutes:0] 101 result.preventativeMaintenanceWorkDone = [total:0, hours:0, minutes:0] 102 result.totalPreventativeWorkDone = [total:0, hours:0, minutes:0, percentage:0] 103 result.totalWorkDone = [total:0, hours:0, minutes:0] 104 105 result.taskList.each() { task -> 106 task.entries.each() { entry -> 107 // Has assets assigned and is Work Done. 108 if( (task.primaryAsset || task.associatedAssets) && entry.entryType.id == 3L ) { 109 if(task.taskType == namedParams.immediateCallout) 110 result.immediateCalloutWorkDone.total += (entry.durationHour*60) + entry.durationMinute 111 if(task.taskType == namedParams.unscheduledBreakin) 112 result.unscheduledBreakinWorkDone.total += (entry.durationHour*60) + entry.durationMinute 113 if(task.taskType == namedParams.preventativeMaintenance) 114 result.preventativeMaintenanceWorkDone.total += (entry.durationHour*60) + entry.durationMinute 115 } 116 } // each() entry 117 } // each() task 118 119 // Work Done hours and minutes. 120 result.immediateCalloutWorkDone.hours = (result.immediateCalloutWorkDone.total / 60).toInteger() 121 result.immediateCalloutWorkDone.minutes = result.immediateCalloutWorkDone.total % 60 122 123 result.unscheduledBreakinWorkDone.hours = (result.unscheduledBreakinWorkDone.total / 60).toInteger() 124 result.unscheduledBreakinWorkDone.minutes = result.unscheduledBreakinWorkDone.total % 60 125 126 result.preventativeMaintenanceWorkDone.hours = (result.preventativeMaintenanceWorkDone.total / 60).toInteger() 127 result.preventativeMaintenanceWorkDone.minutes = result.preventativeMaintenanceWorkDone.total % 60 128 129 // Work Done Totals. 130 result.totalPreventativeWorkDone.total = result.unscheduledBreakinWorkDone.total + result.preventativeMaintenanceWorkDone.total 131 result.totalPreventativeWorkDone.hours = (result.totalPreventativeWorkDone.total / 60).toInteger() 132 result.totalPreventativeWorkDone.minutes = result.totalPreventativeWorkDone.total % 60 133 134 result.totalWorkDone.total = result.immediateCalloutWorkDone.total + result.totalPreventativeWorkDone.total 135 result.totalWorkDone.hours = (result.totalWorkDone.total / 60).toInteger() 136 result.totalWorkDone.minutes = result.totalWorkDone.total % 60 137 138 // Work Done Percentages. 139 try { 140 result.immediateCalloutWorkDone.percentage = (result.immediateCalloutWorkDone.total / result.totalWorkDone.total)*100 141 result.totalPreventativeWorkDone.percentage = (result.totalPreventativeWorkDone.total / result.totalWorkDone.total)*100 142 } 143 catch(ArithmeticException e) { 144 log.error "Could not calculate: Work Done Percentages: "+e 96 145 } 97 146
Note: See TracChangeset
for help on using the changeset viewer.