package com.huatek.busi.task.dataoutput;

import com.huatek.busi.common.SiteConstants.SiteTreeEnum;
import com.huatek.busi.dto.SimulateResultDto;
import com.huatek.busi.service.ISimulateResultService;
import com.huatek.busi.service.dataoutput.DataOutputEntityService;
import com.huatek.busi.task.base.AbstractBusiTaskExecutor;
import com.huatek.busi.vo.dataoutput.OutputEquipmentVo;
import com.huatek.busi.where.SimulateResultSelectVo;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * 数据输出定时任务
 * 
 * @author anker_cheng
 * @date 2019/10/12
 */
@Slf4j
@Component("dataOutputSimulateTask")
public class DataOutputSimulateTask extends AbstractBusiTaskExecutor {


    @Autowired
    ISimulateResultService simulateResultService;
    @Autowired
    private DataOutputEntityService dataOutputEntityService;
    @Override
    public void execute() throws Exception {
        super.execute();
    }

    @Override
    public void execute(LocalDate day) {
        execute(simulateResultService.listSimulate("2","GISmec"),day);
        execute(simulateResultService.listSimulate("2","GISPD"),day);
        execute(simulateResultService.listSimulate("2","assess"),day);
        execute(simulateResultService.listSimulate("3","switch"),day);
        execute(simulateResultService.listSimulate("6","Generator"),day);
        execute(simulateResultService.listSimulate("7","Cable"),day);
    }
    private void execute(List<SimulateResultDto> list, LocalDate day) {
        if (CollectionUtils.isEmpty(list)) {
            return;
        }
        for (SimulateResultDto vo : list) {
            try {
                // 查数据、写文件、保存记录
                dataOutputEntityService.doOutputSimulate(vo,day);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
























