package com.huatek.busi.task.transformer.part;

import java.time.LocalDate;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import com.huatek.busi.service.transformer.TransformerRunStatusService;
import com.huatek.busi.service.transformer.TransformerRunStatusStatisticsService;
import com.huatek.busi.task.base.AbstractBusiTaskExecutor;
import com.huatek.busi.vo.TransformerRunStatusCountVo;

/**
 * 变压器运行工况统计
 * 
 * @author anker_cheng
 * @date 2019/10/28
 */
@Component("transformerRunStatusTask")
public class TransformerRunStatusTask extends AbstractBusiTaskExecutor {
    @Autowired
    private TransformerRunStatusService transformerRunStatusService;
    @Autowired
    private TransformerRunStatusStatisticsService transformerRunStatusStatisticsService;

    @Override
    public void execute(LocalDate day) {
        List<TransformerRunStatusCountVo> list = transformerRunStatusService.getListEquInfo(day);
        if (CollectionUtils.isEmpty(list)) {
            return;
        }
        for (TransformerRunStatusCountVo item : list) {
            transformerRunStatusStatisticsService.saveStatistics(day, item);
        }
    }
}