TestBsthApplication.java
2.96 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.ruoyi;
import com.ruoyi.BsthApplication;
import com.ruoyi.common.cache.NowSchedulingCache;
import com.ruoyi.domain.DriverScheduling;
import com.ruoyi.driver.service.IDriverService;
import com.ruoyi.in.domain.SignIn;
import com.ruoyi.in.service.ISignInService;
import com.ruoyi.pojo.request.DriverRequestVo;
import com.ruoyi.pojo.request.ReportViewRequestVo;
import com.ruoyi.pojo.response.ReportViewResponseVo;
import com.ruoyi.service.ReportService;
import com.ruoyi.utils.ConstDateUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.math.BigDecimal;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = BsthApplication.class)
public class TestBsthApplication {
/**
* 模拟mvc测试对象
*/
@Autowired
private ISignInService signInService;
@Autowired
private ReportService reportService;
@Autowired
private IDriverService driverService;
@Test
public void testAddSignIn() {
// 模拟前端签到
String [] params = new String[] {
"2024-02-19 04:30:06,1,1,0",
"2024-02-19 05:03:06,1,1,0",
"2024-02-19 11:30:30,2,0,0",
"2024-02-19 12:16:15,2,0,0",
"2024-02-19 15:13:03,1,1,0",
"2024-02-19 16:13:03,1,1,0",
"2024-02-19 21:36:03,1,1,0",};
try {
for (int i = 0; i < params.length; i++) {
String[] strings = params[i].split(",");
SignIn signIn = new SignIn();
signIn.setJobCode("722017");
signIn.setCreateTime(ConstDateUtil.parseDate(strings[0]));
signIn.setType(Integer.parseInt(strings[1]));
signIn.setDeviceId("003");
signIn.setAlcoholFlag(Integer.parseInt(strings[2]));
signIn.setAlcoholIntake(new BigDecimal(strings[3]));
signInService.addSignIn(signIn);
}
ReportViewRequestVo vo = new ReportViewRequestVo();
vo.setDate("2024-02-19");
vo.setJobCode("722017");
System.out.println();
for (ReportViewResponseVo responseVo : reportService.getReportScrollViewTable(vo, null)) {
System.out.println(responseVo);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
// 模拟获取人员信息
@Test
public void getDriversTest() {
// 722608
DriverRequestVo vo = new DriverRequestVo();
vo.setJobCode("722608");
vo.setUpdateTime(ConstDateUtil.parseDate("2024-02-17 04:56:56"));
System.out.println(driverService.getDrivers(vo));
vo.setUpdateTime(ConstDateUtil.parseDate("2024-02-17 04:57:01"));
System.out.println(driverService.getDrivers(vo));
}
}