This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit fe0ebb0b71e8e82b902e242ecf2018cde2b7358e Author: Kevin Morin <morin@codelutin.com> Date: Fri Mar 17 14:38:37 2017 +0100 refs #9105 prise en compte de la conf computeQuantitiesSubtotalsByState dans la partie cliente --- .../faxtomail/beans/QuantitiesByRange.java | 19 ++++++++++- .../persistence/entities/EmailTopiaDao.java | 37 ++++++++++++++++++--- .../services/service/EmailServiceImpl.java | 12 +++++-- .../actions/ComputeQuantitiesByRangeAction.java | 38 +++++++++++++++++----- .../i18n/faxtomail-ui-swing_fr_FR.properties | 2 ++ 5 files changed, 92 insertions(+), 16 deletions(-) diff --git a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/beans/QuantitiesByRange.java b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/beans/QuantitiesByRange.java index f6533b7..e1bca53 100644 --- a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/beans/QuantitiesByRange.java +++ b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/beans/QuantitiesByRange.java @@ -38,10 +38,19 @@ public class QuantitiesByRange implements Serializable { private final ImmutableMap<Range, Quantities> quantitiesByRange; + private final Quantities inProgressDemandsQuantities; + + private final Quantities otherDemandsQuantities; + private final Quantities totalQuantities; - public QuantitiesByRange(Map<Range, Quantities> quantitiesByRange, Quantities totalQuantities) { + public QuantitiesByRange(Map<Range, Quantities> quantitiesByRange, + Quantities inProgressDemandsQuantities, + Quantities otherDemandsQuantities, + Quantities totalQuantities) { this.quantitiesByRange = ImmutableMap.copyOf(quantitiesByRange); + this.inProgressDemandsQuantities = inProgressDemandsQuantities; + this.otherDemandsQuantities = otherDemandsQuantities; this.totalQuantities = totalQuantities; } @@ -49,6 +58,14 @@ public class QuantitiesByRange implements Serializable { return quantitiesByRange; } + public Quantities getInProgressDemandsQuantities() { + return inProgressDemandsQuantities; + } + + public Quantities getOtherDemandsQuantities() { + return otherDemandsQuantities; + } + public Quantities getTotalQuantities() { return totalQuantities; } diff --git a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java index 02ac8ce..74f63bc 100644 --- a/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java +++ b/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java @@ -1006,7 +1006,7 @@ public class EmailTopiaDao extends AbstractEmailTopiaDao<Email> { return result; } - public QuantitiesByRange computeQuantitiesByRange(List<MailFolder> folders) { + public QuantitiesByRange computeQuantitiesByRange(List<MailFolder> folders, boolean computeQuantitiesSubtotalsByState) { String allRangesQuery = "SELECT DISTINCT range" + " FROM " + Email.class.getName() + " AS email " + @@ -1026,7 +1026,7 @@ public class EmailTopiaDao extends AbstractEmailTopiaDao<Email> { // do to bug https://hibernate.atlassian.net/browse/HHH-1615 that can be reproduced // on sql server - String query = "SELECT range." + Range.PROPERTY_TOPIA_ID + "," + + String quantitiesByRangeQuery = "SELECT range." + Range.PROPERTY_TOPIA_ID + "," + " SUM(rangeRow." + RangeRow.PROPERTY_PRODUCT_QUANTITY + ") AS prodQ," + " SUM(rangeRow." + RangeRow.PROPERTY_SAV_QUANTITY + ") AS savQ," + " SUM(rangeRow." + RangeRow.PROPERTY_QUOTATION_QUANTITY + ") AS quotQ" + @@ -1049,7 +1049,7 @@ public class EmailTopiaDao extends AbstractEmailTopiaDao<Email> { Long savTotalQuantity = 0L; Long quotationTotalQuantity = 0L; - List<Object[]> queryResuts = findAll(query, args); + List<Object[]> queryResuts = findAll(quantitiesByRangeQuery, args); for (Object[] queryResut : queryResuts) { Range range = rangesById.get(String.valueOf(queryResut[0])); @@ -1074,7 +1074,36 @@ public class EmailTopiaDao extends AbstractEmailTopiaDao<Email> { Quantities totalQuantities = new Quantities(productTotalQuantity, savTotalQuantity, quotationTotalQuantity); - return new QuantitiesByRange(quantitiesByRange, totalQuantities); + Quantities inProgressDemandsQuantities = null; + Quantities otherDemandsQuantities = null; + + if (computeQuantitiesSubtotalsByState) { + String inProgressQuantitiesQuery = "SELECT SUM(rangeRow." + RangeRow.PROPERTY_PRODUCT_QUANTITY + ") AS prodQ," + + " SUM(rangeRow." + RangeRow.PROPERTY_SAV_QUANTITY + ") AS savQ," + + " SUM(rangeRow." + RangeRow.PROPERTY_QUOTATION_QUANTITY + ") AS quotQ" + + " FROM " + Email.class.getName() + " AS email " + + " INNER JOIN email." + Email.PROPERTY_RANGE_ROW + " AS rangeRow" + + " WHERE email." + Email.PROPERTY_MAIL_FOLDER + " IN :folders" + + " AND email." + Email.PROPERTY_TAKEN_BY + " IS NOT NULL" + + " AND email." + Email.PROPERTY_WAITING_STATE + " IS NULL"; + + args = new HashMap<>(); + args.put("folders", folders); + + Object[] queryResut = findUnique(inProgressQuantitiesQuery, args); + Long productInProgressQuantity = (Long) queryResut[0]; + Long savInProgressQuantity = (Long) queryResut[1]; + Long quotationInProgressQuantity = (Long) queryResut[2]; + + inProgressDemandsQuantities = new Quantities(productInProgressQuantity, + savInProgressQuantity, + quotationInProgressQuantity); + otherDemandsQuantities = new Quantities(productTotalQuantity - productInProgressQuantity, + savTotalQuantity - savInProgressQuantity, + quotationTotalQuantity - quotationInProgressQuantity); + } + + return new QuantitiesByRange(quantitiesByRange, inProgressDemandsQuantities, otherDemandsQuantities, totalQuantities); } /* diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java index 5b66473..735f8d0 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java @@ -790,10 +790,18 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe @Override public QuantitiesByRange computeQuantitiesByRange(MailFolder rootFolder) { - // get results by topia id + + MailFolder folderWithComputeQuantitiesByState = rootFolder; + while (folderWithComputeQuantitiesByState.getParent() != null + && folderWithComputeQuantitiesByState.getComputeQuantitiesSubtotalsByState() == null) { + folderWithComputeQuantitiesByState = folderWithComputeQuantitiesByState.getParent(); + } + boolean computeQuantitiesSubtotalsByState = + Boolean.TRUE.equals(folderWithComputeQuantitiesByState.getComputeQuantitiesSubtotalsByState()); + List<MailFolder> folders = getChildrenRecursively(rootFolder); EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); - return emailDao.computeQuantitiesByRange(folders); + return emailDao.computeQuantitiesByRange(folders, computeQuantitiesSubtotalsByState); } @Override diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ComputeQuantitiesByRangeAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ComputeQuantitiesByRangeAction.java index a081491..b2cc0aa 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ComputeQuantitiesByRangeAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ComputeQuantitiesByRangeAction.java @@ -91,19 +91,39 @@ public class ComputeQuantitiesByRangeAction extends AbstractFaxToMailAction<Quan rangeRows.add(row); } - Quantities totalQuantities = quantitiesByRange.getTotalQuantities(); - RangeRowModel row = new RangeRowModel(); - Range total = new RangeImpl(); - total.setLabel(t("faxtomail.rangeRows.quantities.totals.label")); - row.setRange(total); - row.setProductQuantity(totalQuantities.getProductQuantity().intValue()); - row.setSavQuantity(totalQuantities.getSavQuantity().intValue()); - row.setQuotationQuantity(totalQuantities.getQuotationQuantity().intValue()); - rangeRows.add(row); + Quantities inProgressDemandsQuantities = quantitiesByRange.getInProgressDemandsQuantities(); + if (inProgressDemandsQuantities != null) { + RangeRowModel inProgressRow = createRangeRowModelForQuantities(inProgressDemandsQuantities, + t("faxtomail.rangeRows.quantities.inProgress.label")); + rangeRows.add(inProgressRow); + } + + Quantities otherDemandsQuantities = quantitiesByRange.getOtherDemandsQuantities(); + if (otherDemandsQuantities != null) { + RangeRowModel otherDemandsRow = createRangeRowModelForQuantities(otherDemandsQuantities, + t("faxtomail.rangeRows.quantities.otherDemands.label")); + rangeRows.add(otherDemandsRow); + } + + + RangeRowModel totalRow = createRangeRowModelForQuantities(quantitiesByRange.getTotalQuantities(), + t("faxtomail.rangeRows.quantities.totals.label")); + rangeRows.add(totalRow); getModel().setRangeRows(rangeRows); } + protected RangeRowModel createRangeRowModelForQuantities(Quantities quantities, String label) { + RangeRowModel row = new RangeRowModel(); + Range range = new RangeImpl(); + range.setLabel(label); + row.setRange(range); + row.setProductQuantity(quantities.getProductQuantity().intValue()); + row.setSavQuantity(quantities.getSavQuantity().intValue()); + row.setQuotationQuantity(quantities.getQuotationQuantity().intValue()); + return row; + } + @Override public void postSuccessAction() { super.postSuccessAction(); diff --git a/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties b/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties index 847581e..3c2086e 100644 --- a/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties +++ b/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties @@ -275,6 +275,8 @@ faxtomail.pdfEditor.readPdf.error=Erreur lors de la lecture du PDF faxtomail.print.success.message=%s fichiers ont été imprimés faxtomail.quantitiesByRange.button.text=OK faxtomail.quantitiesByRange.title=Quantités par gamme +faxtomail.rangeRows.quantities.inProgress.label=En cours +faxtomail.rangeRows.quantities.otherDemands.label=Autres faxtomail.rangeRows.quantities.totals.label=Totaux faxtomail.rangeRows.table.header.commandNumber=N° commande / devis faxtomail.rangeRows.table.header.commandNumber.tip=N° commande / devis -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.