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

import com.huatek.busi.service.transformer.BusiGeneratorPdService;
import com.huatek.busi.service.transformer.GeneratorPdStatisticsService;
import com.huatek.busi.task.base.AbstractBusiTaskExecutor;
import com.huatek.busi.vo.GeneratorPdCountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

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

/**
 * 发电机局放统计
 */
@Component("generatorPdTask")
public class GeneratorPdTask extends AbstractBusiTaskExecutor {
    @Autowired
    private BusiGeneratorPdService busiGeneratorPdService;

    @Autowired
    private GeneratorPdStatisticsService generatorPdStatisticsService;

    @Override
    public void execute(LocalDate day) {
        doExecute(day);
    }

    private void doExecute(LocalDate day) {
        List<GeneratorPdCountVo> list = busiGeneratorPdService.getListEquInfo(day);
        if (CollectionUtils.isEmpty(list)) {
            return;
        }
        for (GeneratorPdCountVo item : list) {
            generatorPdStatisticsService.saveTransformerPdStatistics(item, day);
        }
    }
}
