Resolved conflicts

This commit is contained in:
nisha
2025-01-09 15:29:14 +05:30
93 changed files with 2958 additions and 510 deletions

View File

@@ -74,4 +74,10 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
" AND activeAmendment.isDeleted = false) ")
Set<ApplicationEvaluationEntity> findEvaluationsWithoutActiveAmendmentsByIds(@Param("applicationEvaluationIds") Set<Long> applicationEvaluationIds);
@Query("SELECT a FROM ApplicationAmendmentRequestEntity a " +
"WHERE a.isDeleted = false " +
"AND a.status NOT IN ('CLOSE', 'EXPIRED') " +
"AND a.endDate BETWEEN :startTime AND :endTime")
List<ApplicationAmendmentRequestEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
}

View File

@@ -1,12 +1,15 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@@ -31,4 +34,33 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
@Query("SELECT a FROM ApplicationEvaluationEntity a WHERE a.isDeleted = false AND a.endDate < :currentDate")
List<ApplicationEvaluationEntity> findAllByIsDeletedFalseAndEndDateBefore(@Param("currentDate") LocalDateTime currentDate);
@Query("SELECT a FROM ApplicationEvaluationEntity a " +
"WHERE a.isDeleted = false " +
"AND a.status NOT IN ('CLOSE', 'EXPIRED') " +
"AND a.endDate BETWEEN :startTime AND :endTime")
List<ApplicationEvaluationEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
// @Query("SELECT AVG(DATEDIFF(DAY, e.startDate, e.endDate)) FROM ApplicationEvaluationEntity e WHERE e.applicationId IN :applicationIds AND e.startDate IS NOT NULL AND e.endDate IS NOT NULL AND e.isDeleted = false ")
@Query("""
SELECT AVG(e.activeDays)
FROM ApplicationEvaluationEntity e
WHERE e.applicationId IN :applicationIds
AND e.activeDays IS NOT NULL
AND e.isDeleted = false
""")
BigDecimal findAverageEvaluationTimeByApplicationIds(@Param("applicationIds") List<Long> applicationIds);
@Query("""
SELECT COUNT(e)
FROM ApplicationEvaluationEntity e
WHERE e.applicationId IN :applicationIds
AND FUNCTION('DATE', e.endDate) BETWEEN :startDate AND :endDate
AND e.isDeleted = false
""")
Long countDueApplicationsBetween(
@Param("applicationIds") List<Long> applicationIds,
@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate
);
}

View File

@@ -61,4 +61,19 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
"FROM ApplicationEntity a " +
"WHERE a.hubId = :hubId AND a.status = 'APPROVED'")
BigDecimal findTotalAmountAcceptedOfApplication(@Param("hubId") Long hubId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.status = 'SUBMIT' AND a.isDeleted = false")
public Long countApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.status = 'EVALUATION' AND a.isDeleted = false")
Long countAssignedApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.status = 'APPROVED' AND a.isDeleted = false")
Long countApprovedApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.status = 'SOCCORSO' AND a.isDeleted = false")
Long countSoccorsoApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT a.id FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.isDeleted = false")
List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId);
}

View File

@@ -1,11 +1,16 @@
package net.gepafin.tendermanagement.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import net.gepafin.tendermanagement.entities.BeneficiaryEntity;
import java.util.List;
@Repository
public interface BeneficiaryRepository extends JpaRepository<BeneficiaryEntity, Long> {
@Query("SELECT u.id FROM UserEntity u JOIN u.beneficiary b WHERE b.id = u.beneficiary.id AND b.hubId = :hubId")
List<Long> findUserIdsByHubIdAndBeneficiaryId(Long hubId);
}

View File

@@ -51,5 +51,6 @@ public interface CallRepository extends JpaRepository<CallEntity, Long> {
@Query("SELECT SUM(c.amount) FROM CallEntity c WHERE c.hub.id = :hubId AND c.status = 'PUBLISH'")
BigDecimal findTotalAmountOfPublishedCalls(@Param("hubId") Long hubId);
List<CallEntity> findByIdIn(@Param("ids") List<Long> ids);
}

View File

@@ -33,5 +33,7 @@ public interface DocumentRepository extends JpaRepository<DocumentEntity, Long>
List<DocumentEntity> findAllByIsDeleteTrue();
List<DocumentEntity> findAllByIdInAndIsDeletedFalse(Set<Long> documentIds);
List<DocumentEntity> findBySourceIdInAndSourceAndIsDeletedFalse(Set<Long> sourceId, String type);
}

View File

@@ -0,0 +1,13 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.ExpirationConfigEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ExpirationConfigRepository extends JpaRepository<ExpirationConfigEntity, Long> {
List<ExpirationConfigEntity> findByTypeAndIsDeletedFalse(String type);
}

View File

@@ -0,0 +1,20 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.NotificationEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> {
NotificationEntity findByIdAndIsDeletedFalse(Long id);
List<NotificationEntity> findByUserIdAndIsDeletedFalse(Long userId);
List<NotificationEntity> findByUserIdAndUserWithCompanyIdAndIsDeletedFalseAndStatusIn(Long userId, Long userWithCompanyId, List<String> statuses);
List<NotificationEntity> findByUserIdAndIsDeletedFalseAndStatusIn(Long userId, List<String> statuses);
List<NotificationEntity> findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(Long userWithCompanyId, Long userId);
}

View File

@@ -0,0 +1,8 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface NotificationTypeRepository extends JpaRepository<NotificationTypeEntity, Long> {
NotificationTypeEntity findByNotificationNameAndIsDeletedFalse(String value);
}

View File

@@ -35,4 +35,5 @@ public interface UserActionsRepository extends JpaRepository<UserActionEntity, L
@Param("hubId") Long hubId,
Pageable pageable);
UserActionEntity findUserActionByIdAndIsDeletedFalse(Long id);
}

View File

@@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -12,9 +14,16 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
UserEntity findByBeneficiaryId(Long beneficiaryId);
Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
// Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
@Query("SELECT u FROM UserEntity u WHERE LOWER(u.email) = LOWER(:email) AND u.hub.uniqueUuid = :hubUuid AND u.roleEntity.roleType <> :roleType")
Optional<UserEntity> findUserExcludingRoleType(
@Param("email") String email,
@Param("hubUuid") String hubUuid,
@Param("roleType") String roleType
);
// boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
List<UserEntity> findByRoleEntityIdInAndHubId(List<Long> roleIds, Long hubId);
@@ -24,5 +33,29 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
// Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
@Query("SELECT COUNT(u) > 0 " +
"FROM UserEntity u " +
"WHERE LOWER(u.email) = LOWER(:email) " +
"AND u.hub.uniqueUuid = :hubUuid " +
"AND u.roleEntity.roleType <> :beneficiaryRoleType")
Boolean existsByEmailIgnoreCaseForNonBeneficiaries(@Param("email") String email,
@Param("hubUuid") String hubUuid,
@Param("beneficiaryRoleType") String beneficiaryRoleType);
@Query("SELECT COUNT(u) > 0 " +
"FROM UserEntity u " +
"WHERE LOWER(u.email) = LOWER(:email) " +
"AND u.hub.uniqueUuid = :hubUuid " +
"AND u.roleEntity.roleType = :beneficiaryRoleType")
Boolean existsByEmailIgnoreCaseForBeneficiaries(@Param("email") String email,
@Param("hubUuid") String hubUuid,
@Param("beneficiaryRoleType") String beneficiaryRoleType);
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
List<UserEntity> findByRoleEntity_RoleTypeAndHubId(String roleType, Long hubId);
}

View File

@@ -1,22 +1,23 @@
package net.gepafin.tendermanagement.repositories;
import java.util.List;
import java.util.Optional;
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
import java.util.List;
import java.util.Optional;
public interface UserWithCompanyRepository extends JpaRepository<UserWithCompanyEntity, Long> {
void deleteByCompanyIdAndIsDeletedFalse(Long companyId);
void deleteByCompanyIdAndIsDeletedFalse(Long companyId);
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
@Query("SELECT u FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.companyId = :companyId AND u.isDeleted = false")
UserWithCompanyEntity findByUserIdAndCompanyIdAndIsDeletedFalseForNotification(Long userId, Long companyId);
}