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