MainTest.java 2.76 KB
package com.viontech.fanxing.query;

import cn.hutool.poi.excel.cell.FormulaCellValue;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.vo.TrafficVo;
import com.viontech.fanxing.query.model.export.ETrafficModel;
import com.viontech.fanxing.query.runner.ExportDataJob;
import com.viontech.fanxing.query.service.adapter.TrafficService;
import com.viontech.fanxing.query.service.main.OpsClientService;
import com.viontech.keliu.util.DateUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

/**
 * .
 *
 * @author 谢明辉
 * @date 2021/11/26
 */

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
public class MainTest {
    @Resource
    private OpsClientService opsClientService;

    @Resource
    private TrafficService trafficService;

    @Test
    public void test() {
        Traffic traffic = trafficService.selectByPrimaryKey(5808875);
        TrafficVo trafficVo = new TrafficVo(traffic);

        ETrafficModel e = new ETrafficModel();
        Date eventTime = trafficVo.getEventTime();
        e.setEventTime(DateUtil.format(DateUtil.FORMAT_FULL, eventTime));
        e.setPicName(new FormulaCellValue("HYPERLINK(\"https://www.baidu.com/\",\"下载\")"));
        e.setLocation(trafficVo.getLocationName());
        e.setPlateNumber(trafficVo.getPlateNumber());
        Map<String, DictCode> vehicleTypeDict = opsClientService.vehicleTypeDict();
        Map<String, DictCode> vehicleColorDict = opsClientService.vehicleColorDict();
        Map<String, DictCode> plateColorDict = opsClientService.plateColorDict();
        Map<String, DictCode> vehicleBrandDict = opsClientService.vehicleBrandDict();
        String plateColor = Optional.ofNullable(plateColorDict.get(trafficVo.getPlateColor())).map(DictCode::getName).orElse("未识别");
        String vehicleType = Optional.ofNullable(vehicleTypeDict.get(trafficVo.getVehicleType())).map(DictCode::getName).orElse("未识别");
        String vehicleBrand = Optional.ofNullable(vehicleBrandDict.get(trafficVo.getVehicleLogo())).map(DictCode::getName).orElse("未识别");
        String vehicleColor = Optional.ofNullable(vehicleColorDict.get(trafficVo.getVehicleColor())).map(DictCode::getName).orElse("未识别");
        e.setPlateColor(plateColor);
        e.setVehicleType(vehicleType);
        e.setVehicleBrand(vehicleBrand);
        e.setVehicleColor(vehicleColor);
    }

}