package com.tofly.xrtygis.handle.statistical;

import com.tofly.xrtygis.custom.util.DateTimeUtil;
import com.tofly.xrtygis.service.IndicatorCorrectionService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.Date;

@Component
@Slf4j
public class TotalStatisticalHandler {
    @Autowired
    private IndicatorCorrectionService indicatorCorrectionService;

    /**
     * 总各项指标数据统计(每月)
     * @param param
     * @return
     */
    @XxlJob("totalStatistical")
    public ReturnT<String> totalStatistical(String param) {
        long l = System.currentTimeMillis();
        LocalDate firstDayOfCurrentMonth = DateTimeUtil.getFirstDayOfCurrentMonth();
        Date date = DateTimeUtil.localDateToDate(firstDayOfCurrentMonth);
        log.info("开始同步总合计各项每月数据统计,月份{}",date.getMonth()+1);
        indicatorCorrectionService.totalCalculate(date);
        long l1 = System.currentTimeMillis();
        log.info("同步结束总合计各项每月数据统计,用时{}mm",l1-l);
        return ReturnT.SUCCESS;
    }
}
