package com.njcn.influx.service.impl;

import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.imapper.EvtDataMapper;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.pojo.dto.EventQueryDTO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.cs.EntData;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.service.EvtDataService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Description:
 * Date: 2023/8/30  19:08【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
@RequiredArgsConstructor
public class EvtDataServiceImpl implements EvtDataService {
    private final EvtDataMapper commonMapper;
    @Override
    @Deprecated
    public List<EntData> getEventData(EventQueryDTO eventQueryDTO) {
        InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("evt_data", EntData.class);
        influxQueryWrapper.select(EntData::getLineId,EntData::getTarget,EntData::getTime,EntData::getTime,
                        EntData::getEvtVva,EntData::getSec,EntData::getEvtVvaphase,EntData::getEvtVvadepth,
                        EntData::getEvtVvatm)
                .or(InfluxDBTableConstant.LINE_ID,eventQueryDTO.getLineIds())
                .or("target",eventQueryDTO.getTarget());


        return commonMapper.getEventData(influxQueryWrapper);

    }

    @Override
    public EventDataSetDTO getEventDataSet(String tableName, String uuid, String columnName) {
        InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(tableName, EventDataSetDTO.class);
        influxQueryWrapper.select(columnName,InfluxDBTableConstant.VALUE)
                .eq(InfluxDBTableConstant.UUID,uuid);


        return commonMapper.getEventDataSet(influxQueryWrapper);
    }
}
