package com.pqs9300.serviceimpl.report;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pqs9300.mapper.report.GetDistortionDataMapper;
import com.pqs9300.pojo.report.Condition;
import com.pqs9300.pojo.report.ReportValue;
import com.pqs9300.service.report.GetDistortionDataService;

@Service
public class GetDistortionDataServiceImpl implements GetDistortionDataService {
    @Autowired
    private GetDistortionDataMapper getDistortionDataMapper;

    @Override
    public List<ReportValue> getDistortionData(Condition condition) {
        List<ReportValue> list = new ArrayList<>();
        //获取电压畸变率
        List<ReportValue> listU = getDistortionDataMapper.getDistortionData(condition, "V");

        //获取电流畸变率
        List<ReportValue> listI = getDistortionDataMapper.getDistortionData(condition, "I");

        //添加之前判断数据库是否有数据，如果没有数据模拟数据添加到集合中
        RegroupData.regroupData(listU, true);
        RegroupData.regroupData(listI, true);
        list.addAll(listU);
        list.addAll(listI);

        return list;
    }

    @Override
    public List<ReportValue> getDistortionData(Condition condition, String s) {
        List<ReportValue> list = getDistortionDataMapper.getHDistortionData(condition, s);
        return list;
    }
}
