use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class CatchEvolutionProgressHandler method initCatchEvolutionProgressDTO.
protected CatchEvolutionProgressDTO initCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, FaReportDocumentType faReportDocumentType, Map<String, Double> speciesCumulatedWeight) {
CatchSummaryListDTO onboard = new CatchSummaryListDTO();
CatchSummaryListDTO cumulated = new CatchSummaryListDTO();
Map<String, CatchSummaryListDTO> catchEvolution = new TreeMap<>();
catchEvolution.put("onboard", onboard);
catchEvolution.put("cumulated", cumulated);
CatchEvolutionProgressDTO catchEvolutionProgressDTO = new CatchEvolutionProgressDTO();
catchEvolutionProgressDTO.setActivityType(fishingActivity.getTypeCode());
catchEvolutionProgressDTO.setCatchEvolution(catchEvolution);
catchEvolutionProgressDTO.setReportType(faReportDocumentType.name());
for (Map.Entry scw : speciesCumulatedWeight.entrySet()) {
SpeciesQuantityDTO speciesQuantityDTO = new SpeciesQuantityDTO();
speciesQuantityDTO.setSpeciesCode((String) scw.getKey());
Double weight = (Double) scw.getValue();
speciesQuantityDTO.setWeight(weight);
cumulated.getSpeciesList().add(speciesQuantityDTO);
cumulated.setTotal(cumulated.getTotal() + weight);
}
return catchEvolutionProgressDTO;
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchMapper method mapCatchesToSummaryDTO.
/**
* Depending on the catch type (typeCode->FaCatchEntity) returns a DTO containing the sums of ONBOARD and
* LANDED fishQuantity and species.
*
* @param faCatches
* @return
*/
public Map<String, CatchSummaryListDTO> mapCatchesToSummaryDTO(List<Object[]> faCatches) {
Map<String, CatchSummaryListDTO> catchSummary = new HashMap<>();
CatchSummaryListDTO landedSummary = new CatchSummaryListDTO();
CatchSummaryListDTO onBoardSummary = new CatchSummaryListDTO();
catchSummary.put("landed", landedSummary);
catchSummary.put("onboard", onBoardSummary);
if (CollectionUtils.isEmpty(faCatches)) {
return catchSummary;
}
for (Object[] faCatch : faCatches) {
String typeCode = ((String) faCatch[0]).toUpperCase();
String speciesCode = (String) faCatch[1];
String areaName = (String) faCatch[2];
Double weight = (Double) faCatch[3];
if ("UNLOADED".equals(typeCode)) {
landedSummary.addSpecieAndQuantity(speciesCode, weight, areaName);
} else if ("ONBOARD".equals(typeCode) || "KEPT_IN_NET".equals(typeCode) || "TAKEN_ONBOARD".equals(typeCode)) {
onBoardSummary.addSpecieAndQuantity(speciesCode, weight, areaName);
}
}
return catchSummary;
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class CatchEvolutionProgressHandler method handleCumulatedCatchNoDeletion.
protected void handleCumulatedCatchNoDeletion(FaCatchEntity faCatch, CatchEvolutionProgressDTO catchEvolutionProgressDTO, Map<String, Double> speciesCumulatedWeight) {
CatchSummaryListDTO cumulated = catchEvolutionProgressDTO.getCatchEvolution().get("cumulated");
handleCumulatedCatch(faCatch, cumulated, speciesCumulatedWeight, false);
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class CatchEvolutionProgressHandler method handleOnboardCatch.
protected void handleOnboardCatch(FaCatchEntity faCatch, CatchEvolutionProgressDTO catchEvolutionProgressDTO) {
CatchSummaryListDTO onboard = catchEvolutionProgressDTO.getCatchEvolution().get("onboard");
String speciesCode = faCatch.getSpeciesCode();
boolean exists = false;
onboard.setTotal(onboard.getTotal() + faCatch.getCalculatedWeightMeasure());
for (SpeciesQuantityDTO speciesQuantityDTO : onboard.getSpeciesList()) {
if (speciesQuantityDTO.getSpeciesCode().equalsIgnoreCase(speciesCode)) {
speciesQuantityDTO.setWeight(speciesQuantityDTO.getWeight() + faCatch.getCalculatedWeightMeasure());
exists = true;
break;
}
}
if (!exists) {
SpeciesQuantityDTO speciesQuantityDTO = new SpeciesQuantityDTO();
speciesQuantityDTO.setSpeciesCode(speciesCode);
speciesQuantityDTO.setWeight(faCatch.getCalculatedWeightMeasure());
onboard.getSpeciesList().add(speciesQuantityDTO);
}
}
Aggregations