package com.nokia.tsl_data;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import com.nokia.tsl_data.dao.TargetTsRatioMapper;
import com.nokia.tsl_data.service.TaskService;
import com.nokia.tsl_data.util.TextUtil;

@SpringBootTest
class TslDataApplicationTest {

    @Autowired
    private TaskService taskService;

    @Test
    void test() {
        taskService.generateReportV3("20240107");
    }

    @Autowired
    private TargetTsRatioMapper targetTsRatioMapper;

    @Test
    void test2() {
        String path = "/home/lfq/Documents/code/tsl-data/doc/数据订阅/客户提供/abc.txt";
        List<String> lines = TextUtil.readLines(path);
        lines.forEach(line -> {
            String[] split = line.split("\t");
            String city = split[0];
            for (int i = 1; i < split.length; i++) {
                String month = "2024" + (i >= 10 ? i : "0" + i);
                double target = Double.parseDouble(split[i]);
                System.out.println(city + "==" + month + "==" + target);
                targetTsRatioMapper.updateServiceRequestTargetRatio(month, city, target);
            }
        });
    }
}