package cn.cecep.talroad.controller;

import cn.cecep.talroad.domain.PcFactoryPollutantEmissionsRank;
import cn.cecep.talroad.mapper.SEnvGasMonRealMapper;
import cn.cecep.talroad.mapper.SEnvWaterMonRealMapper;
import cn.cecep.talroad.service.IPcFactoryPollutantEmissionsRankService;
import cn.cecep.talroad.vo.SEnvGasMonRealVo;
import cn.cecep.talroad.vo.SEnvWaterMonRealVo;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author changyw
 * @date 2023/2/13
 */
@Api(tags = "统计数据-任务")
@RestController
@RequestMapping("/dataTask")
public class PcGenerationPollutantRankDataTaskController {

    @Autowired
    private SEnvGasMonRealMapper sEnvGasMonRealMapper;

    @Autowired
    private SEnvWaterMonRealMapper sEnvWaterMonRealMapper;

    @Autowired
    private IPcFactoryPollutantEmissionsRankService pcFactoryPollutantEmissionsRankService;


//    @RequestMapping("/generationPollutantEmissionsRankDataTask")
//    public void generationPollutantEmissionsRankDataTask() {
//        String thisYear = DateUtil.thisYear() + "";
//        // 废气 年度实际排放
//        List<SEnvGasMonRealVo> sEnvGasMonRealVos = sEnvGasMonRealMapper.selectSEnvGasMonRealListByYear(thisYear);
//
//        // 废水 年度实际排放
//        List<SEnvWaterMonRealVo> sEnvWaterMonRealVos = sEnvWaterMonRealMapper.selectSEnvWaterMonRealListByYear(thisYear);
//
//        List<PcFactoryPollutantEmissionsRank> collect = sEnvGasMonRealVos.stream()
//                .map(sEnvGasMonRealVo -> {
//                    List<PcFactoryPollutantEmissionsRank> objects = Lists.newArrayList();
////                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvGasMonRealVo.getFactoryId(), "废气", "SO2", "", sEnvGasMonRealVo.getSo2(), "", "", "0"));
////                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvGasMonRealVo.getFactoryId(), "废气", "NOx", "", sEnvGasMonRealVo.getNox(), "", "", "0"));
////                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvGasMonRealVo.getFactoryId(), "废气", "颗粒物", "", sEnvGasMonRealVo.getPm(), "", "", "0"));
////                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvGasMonRealVo.getFactoryId(), "废气", "VOCs", "", sEnvGasMonRealVo.getVocs(), "", "", "0"));
//                    return objects;
//                })
//                .flatMap(Collection::stream)
//                .collect(Collectors.toList());
//
//        collect.addAll(sEnvWaterMonRealVos.stream()
//                .map(sEnvWaterMonRealVo -> {
//                    List<PcFactoryPollutantEmissionsRank> objects = Lists.newArrayList();
//                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvWaterMonRealVo.getFactoryId(), "废水", "COD", "", sEnvWaterMonRealVo.getCodConcentration(), "", "", "0"));
//                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvWaterMonRealVo.getFactoryId(), "废水", "氨氮", "", sEnvWaterMonRealVo.getAmmoniaNitrogen(), "", "", "0"));
//                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvWaterMonRealVo.getFactoryId(), "废水", "总氮", "", sEnvWaterMonRealVo.getNitrogenConcentration(), "", "", "0"));
//                    objects.add(new PcFactoryPollutantEmissionsRank(sEnvWaterMonRealVo.getFactoryId(), "废水", "总磷", "", sEnvWaterMonRealVo.getPhosphorusConcentration(), "", "", "0"));
//                    return objects;
//                })
//                .flatMap(Collection::stream)
//                .collect(Collectors.toList()));
//        pcFactoryPollutantEmissionsRankService.saveOrUpdateBatch(collect);
//    }

}
