RefuelRepository.java
4.07 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.bsth.repository;
import java.util.List;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.bsth.entity.Cars;
import com.bsth.entity.Refuel;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.repository.BaseRepository;
/**
* Created in 19/9/3.
*/
public interface RefuelRepository extends BaseRepository<Refuel, Long> {
@Query(value="select r.date_str, r.line_name, r.car, r.driver, r.in_oil, r.out_oil, r.in_station0, r.in_station5, "
+"r.oil_card0, r.oil_card10, r.east_station0, r.east_station10, r.out_station0, r.out_station10, r.id, "
+"r.date, r.create_by, r.create_date, r.update_by, r.update_date "
+"from bsth_c_refuel r where binary r.date_str = ?1 and r.car like ?2 and r.driver like ?3", nativeQuery=true)
List<Refuel> findByDate(String date, String car, String driver);
@Query(value="select r from Refuel r where r.dateStr = ?1 and r.car = ?2 and r.driver = ?3")
List<Refuel> selectByCarAndDriver(String date, String car, String driver);
@Query(value="select r from Refuel r where r.dateStr = ?1 and r.lineName = ?2 and r.car = ?3 and r.driver = ?4")
List<Refuel> selectByDateAndCar(String date, String line, String car, String driver);
@EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
@Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.clZbh = ?2 and s.jGh = ?3")
List<ScheduleRealInfo> scheduleByDate(String date, String clZbh, String jGh);
@EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
@Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.clZbh like ?2 and s.xlBm = ?3 order by s.clZbh asc")
List<ScheduleRealInfo> scheduleByDateAndLine(String date, String clZbh, String xlBm);
@EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
@Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1 and s.clZbh = ?2")
List<ScheduleRealInfo> scheduleByDateAndCar(String date, String clZbh);
@Transactional
@Modifying
@Query(value="INSERT INTO bsth_c_refuel(" +
"date, date_str, line_name, car, driver, out_oil, in_oil, in_station0, in_station5, oil_card0, oil_card10, east_station0, east_station10, out_station0, out_station10, create_by, create_date)" +
" VALUES(" +
"str_to_date(?1,'%Y-%m-%d'),?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,str_to_date(?17,'%Y-%m-%d %H:%i:%s'))", nativeQuery=true)
void insertData(String date, String dateStr, String lineName, String car, String driver, String outOil, String inOil, String inStation0, String inStation5, String oilCard0, String oilCard10,
String eastStation0, String eastStation10, String outStation0, String outStation10, String createBy, String createDate);
@Transactional
@Modifying
@Query(value="update bsth_c_refuel set date=str_to_date(?2,'%Y-%m-%d'), date_str=?3, line_name=?4, car=?5, driver=?6, out_oil=?7, in_oil=?8,"
+ " in_station0=?9, in_station5=?10, oil_card0=?11, oil_card10=?12, east_station0=?13, east_station10=?14, out_station0=?15, out_station10=?16,"
+ " update_by=?17, update_date=str_to_date(?18,'%Y-%m-%d %H:%i:%s') where id=?1", nativeQuery=true)
public void update(long id, String date, String dateStr, String lineName, String car, String driver, String outOil, String inOil, String inStation0, String inStation5,
String oilCard0, String oilCard10, String eastStation0, String eastStation10, String outStation0, String outStation10, String updateBy, String updateDate);
@Query(value="select s from Cars s where s.insideCode=?1")
List<Cars> findCarsByCode(String insideCode);
@Query(value="select s from Cars s where s.sfdc=?1 and insideCode like ?2 order by s.insideCode asc")
List<Cars> findCarsBySfdc(Boolean sfdc, String insideCode);
}