r357 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions/project webapp/WEB-INF/jsp
Author: meynier Date: 2013-07-01 14:32:53 +0200 (Mon, 01 Jul 2013) New Revision: 357 Url: http://chorem.org/projects/chorem/repository/revisions/357 Log: updated multi-project dashboard Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/QuotationCalculation.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardMultiProject.jsp Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-07-01 10:51:28 UTC (rev 356) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-07-01 12:32:53 UTC (rev 357) @@ -1,10 +1,12 @@ package org.chorem.webmotion.actions.project; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -119,7 +121,16 @@ public Render multiProjectFilter(ChoremClient client, Date from, Date to) { System.out.println(from + "," + to); - if(from != null && to != null) { + if(from == null || to == null) { + Calendar now = new GregorianCalendar(); + Calendar gFrom = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + , now.getActualMinimum(Calendar.DAY_OF_MONTH)); + Calendar gTo = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + , now.getActualMaximum(Calendar.DAY_OF_MONTH)); + from = gFrom.getTime(); + to = gTo.getTime(); + + } WikittyQueryMaker quotationQueryMaker = new WikittyQueryMaker(); WikittyQuery quotationQuery = quotationQueryMaker.or() .bw(Interval.FQ_FIELD_INTERVAL_BEGINDATE, from, to) @@ -132,18 +143,17 @@ HashMap<Quotation, QuotationCalculation> calculations = new HashMap<Quotation, QuotationCalculation>(); for(Quotation q : quotations) { - calculations.put(q, new QuotationCalculation(q, client)); + QuotationCalculation calc = new QuotationCalculation(q, client); + calc.calculate(); + calculations.put(q, calc); } + return renderView("dashboardMultiProject.jsp", "title", "Tableau de bord projets", "quotations", quotations, "calculations", calculations); - } - else { - return renderView("dashboardMultiProject.jsp", - "title", "Tableau de bord projets"); - } + } Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/QuotationCalculation.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/QuotationCalculation.java 2013-07-01 10:51:28 UTC (rev 356) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/QuotationCalculation.java 2013-07-01 12:32:53 UTC (rev 357) @@ -19,11 +19,23 @@ private ChoremClient client; private static final int SEC_PER_HOUR = 3600; private static final int WORKING_HOURS_PER_DAY = 7; + private Double tjm = null; + private Double realDays = null; + private Double deltaDays = null; + private Double realTjm = null; public QuotationCalculation(Quotation q, ChoremClient client) { this.q = q; this.client = client; } + + public void calculate() { + this.tjm = tjm(); + this.realDays = realDays(); + this.deltaDays = deltaDays(); + this.realTjm = realTjm(); + } + public double tjm() { double amount = q.getAmount(); double nbDays = q.getEstimatedDays(); @@ -32,8 +44,8 @@ } - private double getSecondPeriod(Date start, Date end) { - return end.getTime()-start.getTime(); + private double getPeriodInSeconds(Date start, Date end) { + return (end.getTime()-start.getTime())/1000; } public double realDays() { @@ -49,16 +61,16 @@ Collection<Time> times = new ArrayList<Time>(); for(Task t : result.getAll()) { WikittyQuery timeQuery = new WikittyQueryMaker() - .eq(Time.ELEMENT_FIELD_TIME_TASK, q) + .eq(Time.ELEMENT_FIELD_TIME_TASK, t) .end(); WikittyQueryResult timeResult = client.findAllByQuery(Time.class, timeQuery); - System.out.println("RESULT : " + timeResult); times.addAll(timeResult.getAll()); } - System.out.println(times); double totalTime = 0; for(Time t : times) { - totalTime += getSecondPeriod(t.getBeginDate(), t.getEndDate()); + System.out.println("HEURE TRAVAILLEES : " + + (getPeriodInSeconds(t.getBeginDate(), t.getEndDate())/SEC_PER_HOUR) ); + totalTime += getPeriodInSeconds(t.getBeginDate(), t.getEndDate()); } return (totalTime / SEC_PER_HOUR) / WORKING_HOURS_PER_DAY; } @@ -81,14 +93,39 @@ } public double deltaDays() { - return q.getEstimatedDays() - realDays(); + return q.getEstimatedDays() - getRealDays(); } public double realTjm() { double amount = q.getAmount(); - double nbDays = realDays(); + double nbDays = getRealDays(); return amount/nbDays; } + public double getTjm() { + if(tjm == null) + return tjm(); + else + return tjm; + } + public double getRealDays() { + if(realDays == null) + return realDays(); + else + return realDays; + } + public double getDeltaDays() { + if(deltaDays == null) + return deltaDays; + else + return deltaDays; + } + public double getRealTjm() { + if(realTjm == null) + return realTjm(); + else + return realTjm; + } + } Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardMultiProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardMultiProject.jsp 2013-07-01 10:51:28 UTC (rev 356) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardMultiProject.jsp 2013-07-01 12:32:53 UTC (rev 357) @@ -53,8 +53,8 @@ }); </script> --> - From : <input type="text" name="from" id="from" class="datepicker" /> - to : <input type="text" name="to" id="to" class="datepicker" /> + From : <input type="text" name="from" id="from" class="datepicker" value="${fn:escapeXml(from)}" /> + to : <input type="text" name="to" id="to" class="datepicker" value="${fn:escapeXml(to)}" /> <input type="submit"/> </div> </div> @@ -85,13 +85,20 @@ </td> <td class="currency"><w:display wikitty="${q.wikitty}" fqfield="Quotation.amount" label=""/></td> <td class="number"><w:display wikitty="${q.wikitty}" fqfield="Quotation.estimatedDays" label=""/></td> - <td class="number">${calculations[q].tjm()}</td> - <td class="number">${calculations[q].realDays()}</td> - <td class="number">${calculations[q].deltaDays()}</td> - <td class="number">${calculations[q].realTjm()}</td> + <f:setLocale value="en_US"/> + <td class="number"> <f:formatNumber type="number" + maxFractionDigits="2" value="${calculations[q].getTjm()}" /></td> + <td class="number"> <f:formatNumber type="number" + maxFractionDigits="2" value="${calculations[q].getRealDays()}" /></td> + <td class="number"> <f:formatNumber type="number" + maxFractionDigits="2" value="${calculations[q].getDeltaDays()}" /></td> + <td class="number"> <f:formatNumber type="number" + maxFractionDigits="2" value="${calculations[q].getRealTjm()}" /></td> + </tr> </tbody> </c:forEach> </table> +
participants (1)
-
meynier@users.chorem.org