package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;

import cn.hutool.core.date.DateUtil;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetBandDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.prepare.harmonic.pojo.po.RStatSubstationMPO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatSubstationVoltageMPOMapper;
import com.njcn.prepare.harmonic.pojo.mysql.po.RStatSubstationVoltageMPO;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatSubstationVoltageMPOService;
import org.springframework.util.CollectionUtils;

/**
 * 
 * Description:
 * Date: 2023/8/4  14:57【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
public class RStatSubstationVoltageMPOServiceImpl extends MppServiceImpl<RStatSubstationVoltageMPOMapper, RStatSubstationVoltageMPO> implements RStatSubstationVoltageMPOService{

    @Override
    public void handler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
        List<RStatSubstationVoltageMPO> result = new ArrayList<>();
        Date date = DateUtil.parse(dataDate);
        LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();



        List<String> zwList = new ArrayList<>();
        List<String> pwList = new ArrayList<>();

        for (DeptGetSubStationDTO datum : data) {
            if (!CollectionUtils.isEmpty(datum.getStationIds())) {
                zwList.addAll(datum.getStationIds());
            }
            if (!CollectionUtils.isEmpty(datum.getPwStationIds())) {
                pwList.addAll(datum.getPwStationIds());
            }
        }

        zwList.addAll(pwList);
        List<String> resultL = zwList.stream().distinct().collect(Collectors.toList());

        if (!CollectionUtils.isEmpty(resultL)) {
            resultL.forEach(temp->{

            });
        }

        if (!CollectionUtils.isEmpty(result)) {
            this.saveOrUpdateBatchByMultiId(result, 500);
        }
    }
}
