package com.fs.task;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

 import com.fs.company.service.IStatisticManageService;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description:
 * @author: Guos
 * @time: 2025/10/23 下午2:18
 */
@RestController
@RequestMapping("/sg/test")
public class SgTestController {

    @Resource
    private SyncTuLinStudentInfoTask syncTuLinStudentInfoTask;

    @Resource
    private IStatisticManageService iStatisticManageService;


    @RequestMapping("/execute")
    public void execute(){
        syncTuLinStudentInfoTask.execute();
    }

    @RequestMapping("/statistic")
    public void executeTask(@RequestParam(required = false) String dateTime){
        Date date = null;
        if (dateTime != null && !dateTime.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                date = sdf.parse(dateTime);
            } catch (ParseException e) {
                // 处理日期解析异常
                e.printStackTrace();
            }
        }
        iStatisticManageService.executeTask(date);
    }

}
