TestBsthApplication.java
3.46 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
90
91
92
93
94
95
96
97
98
99
100
101
package com.ruoyi;
import com.ruoyi.BsthApplication;
import com.ruoyi.common.cache.NowSchedulingCache;
import com.ruoyi.common.utils.bean.BeanUtils;
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() {
// 724778 722104 722576
// 模拟前端签到
String [] params = new String[] {
"2024-03-20 3:45:44,1,1,0",
"2024-03-20 07:45:44,1,1,0",
// "2024-03-20 11:27:57,2,1,0",
// "2024-03-20 11:39:30,2,0,0",
"2024-03-20 12:21:02,2,0,0",
// "2024-03-20 21:45:35,2,1,0",
"2024-03-20 17:45:35,2,1,0",
};
try {
for (int i = 0; i < params.length; i++) {
String[] strings = params[i].split(",");
SignIn signIn1 = new SignIn();
SignIn signIn2 = new SignIn();
SignIn signIn3 = new SignIn();
signIn1.setJobCode("722902");
signIn1.setCreateTime(ConstDateUtil.parseDate(strings[0]));
signIn1.setType(Integer.parseInt(strings[1]));
signIn1.setDeviceId("003");
signIn1.setAlcoholFlag(Integer.parseInt(strings[2]));
signIn1.setAlcoholIntake(new BigDecimal(strings[3]));
signInService.addSignIn(signIn1);
//
// BeanUtils.copyProperties(signIn1,signIn2);
// signIn2.setJobCode("722104");
// signInService.addSignIn(signIn2);
// BeanUtils.copyProperties(signIn1,signIn3);
// signIn3.setJobCode("722576");
// signInService.addSignIn(signIn3);
}
ReportViewRequestVo vo = new ReportViewRequestVo();
vo.setDate("2024-3-19");
vo.setJobCode("722519");
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));
}
}