Search in sources :

Example 1 with CatchSummaryListDTO

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;
}
Also used : CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) SpeciesQuantityDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO) CatchSummaryListDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with CatchSummaryListDTO

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;
}
Also used : HashMap(java.util.HashMap) CatchSummaryListDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO)

Example 3 with CatchSummaryListDTO

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);
}
Also used : CatchSummaryListDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO)

Example 4 with CatchSummaryListDTO

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);
    }
}
Also used : SpeciesQuantityDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO) CatchSummaryListDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO)

Aggregations

CatchSummaryListDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO)4 SpeciesQuantityDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO)2 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1