TestBsthApplication.java 2.96 KB
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));

    }

}