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

    }

}