Changeset 535 for trunk/grails-app
- Timestamp:
- May 16, 2010, 5:47:34 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/ReportController.groovy
r533 r535 44 44 45 45 def reactiveRatio = { 46 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100)47 46 48 47 params.reportTitle = "Reactive Ratio Report" 48 params.logoUrl = resource(dir:'images',file:'logo.png', absolute:true) 49 49 params.currentUser = authService.currentUser 50 params.startDate = dateUtilService.yesterday-14 51 params.endDate = dateUtilService.tomorrow+15 50 51 if(params.startDate == 'struct') 52 params.startDate = dateUtilService.makeDate(params.startDate_year, params.startDate_month, params.startDate_day) 53 else 54 params.startDate = dateUtilService.today-7 55 params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate) 56 57 if(params.endDate == 'struct') 58 params.endDate = dateUtilService.makeDate(params.endDate_year, params.endDate_month, params.endDate_day) 59 else 60 params.endDate = dateUtilService.today 61 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 62 52 63 def dataModel = [taskReportService.getReactiveRatio(params, RCU.getLocale(request))] 53 64 -
trunk/grails-app/services/TaskReportService.groovy
r533 r535 24 24 def result = [:] 25 25 26 def currentUser = authService.currentUser27 def startOfToday = dateUtilService.today28 def startOfYesterday = dateUtilService.yesterday29 def startOfTomorrow = dateUtilService.tomorrow30 def oneWeekAgo = dateUtilService.oneWeekAgo31 32 def paginateParams = [:]33 paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax)34 paginateParams.offset = params?.offset?.toInteger() ?: 035 36 def sort = "task." + (params?.sort ?: "targetStartDate")37 def order = params?.order == "desc" ? "desc" : "asc"38 def orderBy = " order by " + sort + ' ' + order39 40 26 def namedParams = [:] 41 27 namedParams.startDate = params.startDate ?: dateUtilService.today 42 namedParams.endDate = params.endDate ?: dateUtilService.tomorrow 28 namedParams.endDate = params.endDate ?: dateUtilService.today 29 namedParams.endDate++ // Start of next day required. 43 30 namedParams.immediateCallout = TaskType.read(1) 44 31 namedParams.unscheduledBreakin = TaskType.read(2) 45 32 namedParams.preventativeMaintenance = TaskType.read(4) 33 namedParams.notStarted = TaskStatus.read(1) 46 34 47 35 result.taskQuery = "from Task as task \ 48 36 where (task.trash = false \ 37 and task.taskStatus != :notStarted \ 49 38 and task.targetStartDate < :endDate \ 50 39 and task.targetStartDate >= :startDate \ … … 56 45 )" 57 46 58 result.taskQuery = "select distinct task " + result.taskQuery + orderBy59 result.taskList = Task.executeQuery(result.taskQuery, namedParams , paginateParams)47 result.taskQuery = "select distinct task " + result.taskQuery 48 result.taskList = Task.executeQuery(result.taskQuery, namedParams) 60 49 result.taskCount = result.taskList.size() 61 50 62 51 // Counts 63 result.total TaskOnAssetCount = 052 result.totalAssetsOnTasksCount = 0 64 53 result.immediateCalloutCount = 0 65 54 result.unscheduledBreakinCount = 0 66 55 result.preventativeMaintenanceCount = 0 67 56 68 // Count the tasks performed against assets. 57 result.summaryOfCalculationMethod = 'HQL query: \n\n' 58 def tempStringArray = result.taskQuery.split(' ') 59 tempStringArray.each() { 60 if(it != '') result.summaryOfCalculationMethod += it +'\n' 61 } 62 result.summaryOfCalculationMethod += '\n'+'Calculations: '+'\n\n' 63 64 result.summaryOfCalculationMethod += 'totalAssetsOnTasksCount = A count of unique assets on each task. \n' 69 65 result.taskList.each() { task -> 70 66 if(task.primaryAsset) { 71 result.total TaskOnAssetCount++67 result.totalAssetsOnTasksCount++ 72 68 if(task.taskType == namedParams.immediateCallout) result.immediateCalloutCount++ 73 69 if(task.taskType == namedParams.unscheduledBreakin) result.unscheduledBreakinCount++ … … 76 72 task.associatedAssets.each() { associatedAsset -> 77 73 if(associatedAsset.id != task.primaryAsset?.id) { 78 result.total TaskOnAssetCount++74 result.totalAssetsOnTasksCount++ 79 75 if(task.taskType == namedParams.immediateCallout) result.immediateCalloutCount++ 80 76 if(task.taskType == namedParams.unscheduledBreakin) result.unscheduledBreakinCount++ … … 88 84 result.totalPreventativePercentage = 0 89 85 86 result.summaryOfCalculationMethod += 'totalPreventativeCount = unscheduledBreakinCount + preventativeMaintenanceCount\n' 90 87 result.totalPreventativeCount = result.unscheduledBreakinCount + result.preventativeMaintenanceCount 91 88 try { 92 result. immediateCalloutPercentage = (result.immediateCalloutCount / result.totalTaskOnAssetCount)*10093 result. immediateCalloutPercentage = result.immediateCalloutPercentage.toInteger()94 result. totalPreventativePercentage = (result.totalPreventativeCount / result.totalTaskOnAssetCount)*10095 result.totalPreventativePercentage = result.totalPreventativePercentage.toInteger()89 result.summaryOfCalculationMethod += 'immediateCalloutPercentage = (immediateCalloutCount / totalAssetsOnTasksCount)*100 \n' 90 result.summaryOfCalculationMethod += 'totalPreventativePercentage = (totalPreventativeCount / totalAssetsOnTasksCount)*100 \n' 91 result.immediateCalloutPercentage = (result.immediateCalloutCount / result.totalAssetsOnTasksCount)*100 92 result.totalPreventativePercentage = (result.totalPreventativeCount / result.totalAssetsOnTasksCount)*100 96 93 } 97 94 catch(ArithmeticException e) { 95 log.error "Could not calculate percentages: "+e 98 96 } 99 97 -
trunk/grails-app/views/appCore/start.gsp
r533 r535 6 6 <nav:resources override="true"/> 7 7 <resource:tabView skin="tabviewCustom" /> 8 <resource:dateChooser /> 8 9 </head> 9 10 <body> … … 98 99 <tr class="prop"> 99 100 <td valign="top" class="name"> 100 <label>Frequent Reports:</label>101 <label>Frequently Used:</label> 101 102 </td> 102 103 <td valign="top" class="value"> … … 105 106 jasper="reactiveRatio" 106 107 name="Reactive Ratio" 107 format="PDF, HTML, XLS"/> 108 format="PDF, XLS"> 109 <richui:dateChooser name="startDate" format="dd-MM-yyyy" value="${new Date()-7}" /> 110 to 111 <richui:dateChooser name="endDate" format="dd-MM-yyyy" value="${new Date()}" /> 112 </g:jasperReport> 108 113 <br /> 109 114 <g:jasperReport controller="report" … … 111 116 jasper="templatePortrait" 112 117 name="Template (Portrait)" 113 format="PDF, HTML,XLS"/>118 format="PDF, XLS"/> 114 119 <br /> 115 120 <g:jasperReport controller="report" … … 117 122 jasper="templateLandscape" 118 123 name="Template (Landscape)" 119 format="PDF, HTML,XLS"/>124 format="PDF, XLS"/> 120 125 <br /> 121 126 </td>
Note: See TracChangeset
for help on using the changeset viewer.