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.common.CacMonitorTypeCode;
import com.huatek.busi.service.transformer.TransformerPdService;
import com.huatek.busi.service.transformer.TransformerPdStatisticsService;
import com.huatek.busi.task.base.AbstractBusiTaskExecutor;
import com.huatek.busi.vo.TransformerPdCountVo;

/**
 * 局放定时任务
 * 
 * @author anker_cheng
 * @date 2019/10/25
 */
@Component("transfromPdTask")
public class TransfromPdTask extends AbstractBusiTaskExecutor {
    @Autowired
    private TransformerPdService transformerPdService;
    @Autowired
    private TransformerPdStatisticsService transformerPdStatisticsService;

    @Override
    public void execute(LocalDate day) {
        doExecute(CacMonitorTypeCode.TRANSFORMER_PD.getCode(), day);
    }

    private void doExecute(String cacMonitorTypeCode, LocalDate day) {
        List<TransformerPdCountVo> list = transformerPdService.getListEquInfo(cacMonitorTypeCode, day);
        if (CollectionUtils.isEmpty(list)) {
            return;
        }
        for (TransformerPdCountVo item : list) {
            transformerPdStatisticsService.saveTransformerPdStatistics(item, day);
        }
    }
}
