Changeset 544 for trunk/grails-app/services/TaskReportService.groovy
- Timestamp:
- May 24, 2010, 3:48:53 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskReportService.groovy
r542 r544 13 13 // def messageSource 14 14 15 //def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib()15 def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() 16 16 17 17 def paramsMax = 100000 … … 174 174 175 175 result.taskQuery = "select distinct task " + result.taskQuery 176 result.task List = Task.executeQuery(result.taskQuery, namedParams)177 result.taskCount = result.task List.size()176 result.taskQueryList = Task.executeQuery(result.taskQuery, namedParams) 177 result.taskCount = result.taskQueryList.size() 178 178 179 179 // Assets on Tasks Count. 180 180 result.totalAssetsOnTasksCount = 0 181 result.totalDownTime = [total: 0, hours: 0, minutes:0] 181 182 result.assetList = [] 182 183 183 // Add or update asset details in assetList. 184 def addAssetToList = { asset, task -> 184 // Task Details 185 result.taskList = [] 186 187 // Add or update lists. 188 def addToLists = { asset, task -> 185 189 186 190 def downTime = 0 187 191 def faultEntries = Entry.findAllByTaskAndEntryType(task, EntryType.read(1)) 192 def causeEntries = Entry.findAllByTaskAndEntryType(task, EntryType.read(2)) 193 def workDoneEntries = Entry.findAllByTaskAndEntryType(task, EntryType.read(3)) 194 def taskDetails = 'Task #'+task.id+' - '+task.description+'\n' 195 faultEntries.each(){ 196 taskDetails += ' Faults: '+it.comment+' - '+it.enteredBy+', '+g.formatDate(format: "EEE, dd-MMM-yyyy", date: it.dateDone)+'.\n' 197 } 198 causeEntries.each(){ 199 taskDetails += ' Causes: '+it.comment+' - '+it.enteredBy+', '+g.formatDate(format: "EEE, dd-MMM-yyyy", date: it.dateDone)+'.\n' 200 } 201 workDoneEntries.each(){ 202 taskDetails += ' Work Done: '+it.comment+' - '+it.enteredBy+', '+g.formatDate(format: "EEE, dd-MMM-yyyy", date: it.dateDone)+'.\n' 203 } 204 188 205 faultEntries.each() { downTime += (it.durationHour*60 + it.durationMinute) } 206 result.totalDownTime.total += downTime 189 207 190 208 def assetDetails = result.assetList.find { it.id == asset.id } 191 209 if(assetDetails) { 192 210 assetDetails.immediateCalloutCount++ 193 assetDetails.immediateCalloutTaskList.add(task.toString()) 211 assetDetails.downTime += downTime 212 assetDetails.tasks += taskDetails 194 213 } 195 214 else { … … 198 217 immediateCalloutCount: 1, 199 218 downTime: downTime, 200 immediateCalloutTaskList: [task.toString()]]219 tasks: taskDetails] 201 220 202 221 result.assetList << assetDetails 203 222 } 204 } // addA ssetToList223 } // addAToLists 205 224 206 225 // Summary Of Calculations. … … 213 232 214 233 result.summaryOfCalculationMethod += 'totalAssetsOnTasksCount = A count of unique assets on each task. \n' 215 result.task List.each() { task ->234 result.taskQueryList.each() { task -> 216 235 if(task.primaryAsset) { 217 236 result.totalAssetsOnTasksCount++ 218 add AssetToList(task.primaryAsset, task)237 addToLists(task.primaryAsset, task) 219 238 } 220 239 task.associatedAssets.each() { associatedAsset -> 221 240 if(associatedAsset.id != task.primaryAsset?.id) { 222 241 result.totalAssetsOnTasksCount++ 223 add AssetToList(associatedAsset, task)242 addToLists(associatedAsset, task) 224 243 } 225 244 } … … 227 246 } // each() task 228 247 229 // Sort by callout count.248 // Sort assetList by callout count. 230 249 result.assetList.sort {a, b -> b.immediateCalloutCount.compareTo(a.immediateCalloutCount)} 250 251 // Calculate hours and minutes. 252 result.totalDownTime.hours = (result.totalDownTime.total / 60).toInteger() 253 result.totalDownTime.minutes = result.totalDownTime.total % 60 231 254 232 255 // Success.
Note: See TracChangeset
for help on using the changeset viewer.