package com.nokia.tsl_data.controller;

import com.nokia.tsl_data.entity.vo.R;
import com.nokia.tsl_data.service.TaskService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("tsl_data/")
public class ReportGenerateController {

    @Autowired
    private TaskService taskService;
    
    @PostMapping("report/generate/v3")
    public R generateReport(@RequestBody String day) {
        try {
            taskService.generateReportV3(day);
            return R.ok().message(String.format("v3报表账期 %s 生成成功", day));
        } catch (Exception e) {
            log.error(e.getMessage());
            e.printStackTrace();
            return R.error().message(String.format("v3报表账期 %s 生成失败: %s", day, e.getMessage()));
        }
    }

}
