Merge pull request #298 from Kitzanos/feature/GEPAFINBE-221
Allow decimal values for the score in criteria
This commit is contained in:
@@ -2552,8 +2552,8 @@ public class ApplicationEvaluationDao {
|
||||
ApplicationEvaluationEntity evaluationEntity = evaluationEntityOpt.get();
|
||||
String criteriaJson = evaluationEntity.getCriteria();
|
||||
if (criteriaJson != null){
|
||||
Integer totalScore = calculateTotalScore(evaluationEntity.getCriteria());
|
||||
if (totalScore > 40) {
|
||||
BigDecimal totalScore = calculateTotalScore(evaluationEntity.getCriteria());
|
||||
if (totalScore.compareTo(new BigDecimal("40")) > 0) {
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to TECHNICAL_EVALUATION for applicationId: {}", applicationId);
|
||||
}
|
||||
@@ -2565,7 +2565,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
}
|
||||
|
||||
private Integer calculateTotalScore(String criteriaJson){
|
||||
private BigDecimal calculateTotalScore(String criteriaJson){
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// Convert JSON string to List of Maps
|
||||
@@ -2573,16 +2573,19 @@ public class ApplicationEvaluationDao {
|
||||
});
|
||||
|
||||
// Sum all scores (ignoring null scores)
|
||||
Integer totalScore = criteriaList.stream()
|
||||
.mapToInt(obj -> obj.get("score") != null ? ((Number) obj.get("score")).intValue() : 0)
|
||||
.sum();
|
||||
BigDecimal totalScore = criteriaList.stream()
|
||||
.map(obj -> {
|
||||
Object score = obj.get("score");
|
||||
return score != null ? new BigDecimal(score.toString()) : BigDecimal.ZERO;
|
||||
})
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
log.info("Total score calculated successfully: {}", totalScore);
|
||||
return totalScore;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Error parsing criteria JSON. Input: {}. Exception: {}", criteriaJson, e.getMessage(), e);
|
||||
return 0;
|
||||
log.error(" Error parsing criteria JSON: {}", e.getMessage());
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ public class CallDao {
|
||||
criteriaEntity = new EvaluationCriteriaEntity();
|
||||
criteriaEntity.setCall(callEntity);
|
||||
criteriaEntity.setLookupData(lookupDataEntity);
|
||||
criteriaEntity.setScore(0L);
|
||||
criteriaEntity.setScore(BigDecimal.ZERO);
|
||||
criteriaEntity.setIsDeleted(false);
|
||||
actionType = VersionActionTypeEnum.INSERT;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -68,7 +69,7 @@ public class EvaluationCriteriaDao {
|
||||
LookUpDataEntity lookupDataEntity = lookUpDataService.getOrCreateLookUpDataEntity(evaluationCriteriaRequest, LookUpDataEntity.LookUpDataTypeEnum.EVALUATION_CRITERIA);
|
||||
entity.setCall(callEntity);
|
||||
entity.setLookupData(lookupDataEntity);
|
||||
entity.setScore(0L);
|
||||
entity.setScore(BigDecimal.ZERO);
|
||||
if (evaluationCriteriaRequest.getScore() != null) {
|
||||
entity.setScore(evaluationCriteriaRequest.getScore());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "EVALUATION_CRITERIA")
|
||||
@@ -21,7 +23,7 @@ public class EvaluationCriteriaEntity extends BaseEntity {
|
||||
private LookUpDataEntity lookupData;
|
||||
|
||||
@Column(name = "SCORE", nullable = false)
|
||||
private Long score;
|
||||
private BigDecimal score;
|
||||
|
||||
@Column(name ="IS_DELETED", nullable = false)
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
@@ -2,9 +2,11 @@ package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CriteriaRequest {
|
||||
private Long id;
|
||||
private Long score;
|
||||
private BigDecimal score;
|
||||
private Boolean valid;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package net.gepafin.tendermanagement.model.request;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class EvaluationCriteriaReq extends LookUpDataReq{
|
||||
|
||||
private Long score;
|
||||
private BigDecimal score;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package net.gepafin.tendermanagement.model.request;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class EvaluationCriteriaRequest extends LookUpDataReq {
|
||||
|
||||
private Long callId;
|
||||
|
||||
private Long score;
|
||||
private BigDecimal score;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CriteriaResponse {
|
||||
private Long id;
|
||||
private String label;
|
||||
private Long score;
|
||||
private Long maxScore;
|
||||
private BigDecimal score;
|
||||
private BigDecimal maxScore;
|
||||
private List<CriteriaMappedField> criteriaMappedFields;
|
||||
private Boolean valid;
|
||||
}
|
||||
@@ -3,9 +3,11 @@ package net.gepafin.tendermanagement.model.response;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Data
|
||||
public class EvaluationCriteriaResponseBean extends LookUpDataResponse{
|
||||
|
||||
private Long score;
|
||||
private BigDecimal score;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user