Changeset 542 for trunk/grails-app/services
- Timestamp:
- May 23, 2010, 4:43:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskReportService.groovy
r536 r542 10 10 def authService 11 11 def dateUtilService 12 def sessionFactory 12 13 // def messageSource 13 14 … … 18 19 /** 19 20 * Selects and returns the reactive ratio. 20 * @param params The request params, may contain param to specify the search.21 * @param params The request params, may contain params to specify the search. 21 22 * @param locale The locale to use when generating result.message. 22 23 */ … … 34 35 35 36 result.taskQuery = "from Task as task \ 36 where (task.trash = false \37 and task.taskStatus != :notStarted \38 and task.targetStartDate < :endDate \39 and task.targetStartDate >= :startDate \40 and ( \41 task.taskType = :immediateCallout \42 or task.taskType = :unscheduledBreakin \43 or task.taskType = :preventativeMaintenance \44 ) \45 )"37 where (task.trash = false \ 38 and task.taskStatus != :notStarted \ 39 and task.targetStartDate < :endDate \ 40 and task.targetStartDate >= :startDate \ 41 and ( \ 42 task.taskType = :immediateCallout \ 43 or task.taskType = :unscheduledBreakin \ 44 or task.taskType = :preventativeMaintenance \ 45 ) \ 46 )" 46 47 47 48 result.taskQuery = "select distinct task " + result.taskQuery … … 55 56 result.preventativeMaintenanceCount = 0 56 57 58 // Summary Of Calculations. 57 59 result.summaryOfCalculationMethod = 'HQL query: \n\n' 58 60 def tempStringArray = result.taskQuery.split(' ') … … 148 150 return result 149 151 150 } // getQuickSearch 152 } // getReactiveRatio 153 154 /** 155 * Selects and returns Immediate Callouts, grouped by Asset. 156 * @param params The request params, may contain params to specify the search. 157 * @param locale The locale to use when generating result.message. 158 */ 159 def getImmediateCallouts(params, locale) { 160 def result = [:] 161 162 def namedParams = [:] 163 namedParams.startDate = params.startDate ?: dateUtilService.today 164 namedParams.endDatePlusOne = (params.endDate ?: dateUtilService.today)+1 165 namedParams.immediateCallout = TaskType.read(1) 166 167 result.taskQuery = "from Task as task \ 168 where (task.trash = false \ 169 and task.targetStartDate < :endDatePlusOne \ 170 and task.targetStartDate >= :startDate \ 171 and task.taskType = :immediateCallout \ 172 ) \ 173 )" 174 175 result.taskQuery = "select distinct task " + result.taskQuery 176 result.taskList = Task.executeQuery(result.taskQuery, namedParams) 177 result.taskCount = result.taskList.size() 178 179 // Assets on Tasks Count. 180 result.totalAssetsOnTasksCount = 0 181 result.assetList = [] 182 183 // Add or update asset details in assetList. 184 def addAssetToList = { asset, task -> 185 186 def downTime = 0 187 def faultEntries = Entry.findAllByTaskAndEntryType(task, EntryType.read(1)) 188 faultEntries.each() { downTime += (it.durationHour*60 + it.durationMinute) } 189 190 def assetDetails = result.assetList.find { it.id == asset.id } 191 if(assetDetails) { 192 assetDetails.immediateCalloutCount++ 193 assetDetails.immediateCalloutTaskList.add(task.toString()) 194 } 195 else { 196 assetDetails = [id: asset.id, 197 name: asset.name, 198 immediateCalloutCount: 1, 199 downTime: downTime, 200 immediateCalloutTaskList: [task.toString()]] 201 202 result.assetList << assetDetails 203 } 204 } // addAssetToList 205 206 // Summary Of Calculations. 207 result.summaryOfCalculationMethod = 'HQL query: \n\n' 208 def tempStringArray = result.taskQuery.split(' ') 209 tempStringArray.each() { 210 if(it != '') result.summaryOfCalculationMethod += it +'\n' 211 } 212 result.summaryOfCalculationMethod += '\n'+'Calculations: '+'\n\n' 213 214 result.summaryOfCalculationMethod += 'totalAssetsOnTasksCount = A count of unique assets on each task. \n' 215 result.taskList.each() { task -> 216 if(task.primaryAsset) { 217 result.totalAssetsOnTasksCount++ 218 addAssetToList(task.primaryAsset, task) 219 } 220 task.associatedAssets.each() { associatedAsset -> 221 if(associatedAsset.id != task.primaryAsset?.id) { 222 result.totalAssetsOnTasksCount++ 223 addAssetToList(associatedAsset, task) 224 } 225 } 226 227 } // each() task 228 229 // Sort by callout count. 230 result.assetList.sort {a, b -> b.immediateCalloutCount.compareTo(a.immediateCalloutCount)} 231 232 // Success. 233 return result 234 235 } // getImmediateCallouts() 151 236 152 237
Note: See TracChangeset
for help on using the changeset viewer.