1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package common.repository;
import common.model.TkioFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
@Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true)
BigDecimal sumFlowByEmailAndContractCode(String email, String contractCode);
@Transactional
@Modifying
@Query(value = "delete from tkio_flow where email = ?1", nativeQuery = true)
void deleteByEmail(String email);
@Query(value = "select sum(flow) from tkio_flow where contract_code = ?1 and ds >= ?2 and ds <= ?3", nativeQuery = true)
BigDecimal sumFlowByContractCodeAndDs(String code, String startDate, String endDate);
@Query(value = "select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2", nativeQuery = true)
BigDecimal sumFlowByDsAndContractCodes(String startDate, String endDate, ArrayList<String> contractCode);
@Query(value = "select id from tkio_flow where contract_code in (select contract_code from tkio_flow where email = ?1) and ds = ?2", nativeQuery = true)
List<Long> findIdByEmailDs(String email, String yesterday);
@Transactional
@Modifying
@Query(value = "delete from tkio_flow where id in ?1", nativeQuery = true)
void deleteByIds(List<Long> delIdList);
}