r1122 - in trunk: tutti-service/src/main/java/fr/ifremer/tutti/service/catches tutti-service/src/main/resources/i18n tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
Author: kmorin Date: 2013-07-09 15:55:44 +0200 (Tue, 09 Jul 2013) New Revision: 1122 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1122 Log: fixes #2842 [ELEVATION] les ?\195?\169l?\195?\169vations dans le rapport pdf sont fausses Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-09 12:15:45 UTC (rev 1121) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-09 13:55:44 UTC (rev 1122) @@ -28,6 +28,7 @@ import com.google.common.collect.Maps; import fr.ifremer.tutti.TuttiBusinessException; import fr.ifremer.tutti.TuttiTechnicalException; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; @@ -153,33 +154,58 @@ } op.put("totalWeight", totalWeight); - Float totalSortedWeight = catchBatch.getCatchTotalSortedComputedWeight() - + catchBatch.getCatchTotalUnsortedComputedWeight(); - op.put("totalSortedWeight", totalSortedWeight); + op.put("totalSortedWeight", catchBatch.getCatchTotalSortedComputedWeight() + catchBatch.getCatchTotalUnsortedComputedWeight()); // create catches data model + // Species + Map<Species, Map<String, Object>> catches = Maps.newHashMap(); - Float ratio = totalWeight / totalSortedWeight; + Float ratio = (totalWeight - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight(); + Float speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedWeight(); + if (speciesTotalSortedWeight == null) { + speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedComputedWeight(); + } + // ratio total species weight / total sorted sampled species weight + Float speciesRatio = speciesTotalSortedWeight / catchBatch.getSpeciesTotalSampleSortedComputedWeight(); + // create catches rows if (rootSpeciesBatch != null) { List<SpeciesBatch> speciesBatches = rootSpeciesBatch.getChildren(); for (SpeciesBatch batch : speciesBatches) { - createSpeciesCatch(batch, catches, ratio, totalWeight); + createSpeciesCatch(batch, catches, speciesRatio * ratio, totalWeight); } } List<Map<String, Object>> catchList = Lists.newArrayList(catches.values()); + // Benthos + + Float benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedWeight(); + if (benthosTotalSortedWeight == null) { + benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedComputedWeight(); + } + // ratio total benthos weight / total sorted sampled benthos weight + Float benthosRatio = benthosTotalSortedWeight / catchBatch.getBenthosTotalSampleSortedComputedWeight(); + // add the benthos row if (rootBenthosBatch != null) { if (CollectionUtils.isNotEmpty(rootBenthosBatch.getChildren())) { Map<String, Object> benthosCatch = - createBenthosCatch(rootBenthosBatch, catchBatch.getBenthosTotalComputedWeight(), totalWeight); + createBenthosCatch(rootBenthosBatch, ratio * benthosRatio, totalWeight); catchList.add(benthosCatch); } } + // Inert and living not itemized + Map<String, Object> inertLivingNotItemizedCatch = createInertAndLivingNotItemizedCatch(catchBatch, + ratio * speciesRatio, + ratio * benthosRatio, + totalWeight); + if ((Float) inertLivingNotItemizedCatch.get("sortedWeight") > 0f) { + catchList.add(inertLivingNotItemizedCatch); + } + op.put("catches", catchList); operations.add(op); } @@ -232,7 +258,8 @@ Species species = batch.getSpecies(); - Float existingWeight; + Float existingSortedWeight; + Float existingTotalWeight; Map<String, Object> ktch = catches.get(species); if (ktch == null) { ktch = Maps.newHashMap(); @@ -242,46 +269,111 @@ Species speciesWithVerncularCode = persistenceService.getSpeciesByReferenceTaxonIdWithVernacularCode(species.getReferenceTaxonId()); ktch.put("commonName", speciesWithVerncularCode.getVernacularCode()); - existingWeight = 0f; + existingSortedWeight = 0f; + existingTotalWeight= 0f; } else { - existingWeight = (Float) ktch.get("sortedWeight"); + existingSortedWeight = (Float) ktch.get("sortedWeight"); + existingTotalWeight = (Float) ktch.get("totalWeight"); } Float weight = batch.getSampleCategoryWeight(); if (weight == null) { weight = batch.getSampleCategoryComputedWeight(); } - weight += existingWeight; + ktch.put("sortedWeight", weight + existingSortedWeight); - ktch.put("sortedWeight", weight); - Float totalBatchWeight = weight * ratio; - ktch.put("totalWeight", totalBatchWeight); - ktch.put("percentage", 100 * totalBatchWeight / totalWeight); + if (TuttiEntities.isVracSpeciesBatch(batch)) { + weight *= ratio; + } + weight += existingTotalWeight; + + ktch.put("totalWeight", weight); + ktch.put("percentage", 100 * weight / totalWeight); catches.put(species, ktch); } protected Map<String, Object> createBenthosCatch(BatchContainer<BenthosBatch> rootBenthosBatch, - float benthosTotalWeight, + float ratio, float totalWeight) { Map<String, Object> ktch = Maps.newHashMap(); - ktch.put("code", "BENTHOS"); + ktch.put("code", _("tutti.service.operations.exportCatchesReport.specialRows.benthos.code")); ktch.put("scientificName", ""); - ktch.put("commonName", "Benthos"); + ktch.put("commonName", _("tutti.service.operations.exportCatchesReport.specialRows.benthos.name")); - Float weight = 0f; + Float sortedWeight = 0f; + Float benthosTotalWeight = 0f; List<BenthosBatch> benthosBatches = rootBenthosBatch.getChildren(); for (BenthosBatch batch : benthosBatches) { Float batchWeight = batch.getSampleCategoryWeight(); if (batchWeight == null) { batchWeight = batch.getSampleCategoryComputedWeight(); } - weight += batchWeight; + sortedWeight += batchWeight; + if (TuttiEntities.isVracBenthosBatch(batch)) { + batchWeight *= ratio; + } + benthosTotalWeight += batchWeight; } - ktch.put("sortedWeight", weight); + ktch.put("sortedWeight", sortedWeight); ktch.put("totalWeight", benthosTotalWeight); ktch.put("percentage", 100 * benthosTotalWeight / totalWeight); return ktch; } + + protected Map<String, Object> createInertAndLivingNotItemizedCatch(CatchBatch catchBatch, + float speciesRatio, + float benthosRatio, + float totalWeight) { + Map<String, Object> inertLivingNotItemizedCatch = Maps.newHashMap(); + inertLivingNotItemizedCatch.put("code", _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code")); + inertLivingNotItemizedCatch.put("scientificName", ""); + inertLivingNotItemizedCatch.put("commonName", _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name")); + + Float inertLivingNotItemizedSortedWeight = 0f; + Float inertLivingNotItemizedTotalWeight = 0f; + + Float speciesInterWeight = catchBatch.getSpeciesTotalInertWeight(); + if (speciesInterWeight == null) { + speciesInterWeight = catchBatch.getSpeciesTotalInertComputedWeight(); + } + if (speciesInterWeight != null) { + inertLivingNotItemizedSortedWeight += speciesInterWeight; + inertLivingNotItemizedTotalWeight += speciesInterWeight * speciesRatio; + } + + Float speciesLivingNotItemizedWeigth = catchBatch.getSpeciesTotalLivingNotItemizedWeight(); + if (speciesLivingNotItemizedWeigth == null) { + speciesLivingNotItemizedWeigth = catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight(); + } + if (speciesLivingNotItemizedWeigth != null) { + inertLivingNotItemizedSortedWeight += speciesLivingNotItemizedWeigth; + inertLivingNotItemizedTotalWeight += speciesLivingNotItemizedWeigth * speciesRatio; + } + + Float benthosInterWeight = catchBatch.getBenthosTotalInertWeight(); + if (benthosInterWeight == null) { + benthosInterWeight = catchBatch.getBenthosTotalInertComputedWeight(); + } + if (benthosInterWeight != null) { + inertLivingNotItemizedSortedWeight += benthosInterWeight; + inertLivingNotItemizedTotalWeight += benthosInterWeight * benthosRatio; + } + + Float benthosLivingNotItemizedWeight = catchBatch.getBenthosTotalLivingNotItemizedWeight(); + if (benthosLivingNotItemizedWeight == null) { + benthosLivingNotItemizedWeight = catchBatch.getBenthosTotalLivingNotItemizedComputedWeight(); + } + if (benthosLivingNotItemizedWeight != null) { + inertLivingNotItemizedSortedWeight += benthosLivingNotItemizedWeight; + inertLivingNotItemizedTotalWeight += benthosLivingNotItemizedWeight * benthosRatio; + } + + inertLivingNotItemizedCatch.put("sortedWeight", inertLivingNotItemizedSortedWeight); + inertLivingNotItemizedCatch.put("totalWeight", inertLivingNotItemizedTotalWeight); + inertLivingNotItemizedCatch.put("percentage", 100 * inertLivingNotItemizedTotalWeight / totalWeight); + + return inertLivingNotItemizedCatch; + } } Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties =================================================================== --- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-09 12:15:45 UTC (rev 1121) +++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-09 13:55:44 UTC (rev 1122) @@ -119,6 +119,10 @@ tutti.service.operations.computeWeights.error.species.incoherentTotalSorted=Le poids total Vrac des espèces est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié tutti.service.operations.computeWeights.error.species.noWeight=Espèces - Le lot de %s/%s/%s n'a pas de poids tutti.service.operations.exportCatchesReport.error=Erreur lors de la génération du rapport des captures +tutti.service.operations.exportCatchesReport.specialRows.benthos.code=BENTHOS +tutti.service.operations.exportCatchesReport.specialRows.benthos.name=Benthos +tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code=INERVEG +tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name=Inerte et végétal tutti.service.persistence.checkArchiveDb.error=L'archive de base de données %1s ne contient pas le dossier %2s tutti.service.persistence.checkImportstructure.fileNotExist=L'archive de base de données %s n'existe pas tutti.service.persistence.checkImportstructure.tooManyChildren=L'archive de base de données %s ne doit avoir qu'un sous-dossier Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-07-09 12:15:45 UTC (rev 1121) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-07-09 13:55:44 UTC (rev 1122) @@ -148,7 +148,7 @@ } if (model.getBenthosTotalSortedWeight() != null && model.getBenthosTotalSortedWeight() >= totalBenthosSortedWeight - && model.getBenthosTotalSortedWeight() < (1 + rate / 100) * totalSpeciesSortedWeight) { + && model.getBenthosTotalSortedWeight() < (1 + rate / 100) * totalBenthosSortedWeight) { // Si le "Poids total VRAC" est saisi est que sa valeur // est supérieure de moins de x% (x en configuration)
participants (1)
-
kmorin@users.forge.codelutin.com