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.GetPowerDataMapper;
import com.pqs9300.pojo.report.Condition;
import com.pqs9300.pojo.report.ReportValue;
import com.pqs9300.service.report.GetPowerDataService;

@Service
public class GetPowerDataServiceImpl implements GetPowerDataService {
    @Autowired
    private GetPowerDataMapper getPowerDataMapper;

    @Override
    public List<ReportValue> getPowerData(Condition condition) {
        List<ReportValue> list = new ArrayList<>();
        //获取有功功率
        List<ReportValue> listP = getPowerDataMapper.getPower(condition, "P");
        //获取无功功率
        List<ReportValue> listQ = getPowerDataMapper.getPower(condition, "Q");
        //获取视在功率
        List<ReportValue> listS = getPowerDataMapper.getPower(condition, "S");

        RegroupData.regroupData(listP, true, false);
        RegroupData.regroupData(listQ, true, false);
        RegroupData.regroupData(listS, true, false);
        list.addAll(listP);
        list.addAll(listQ);
        list.addAll(listS);

        return list;
    }

    @Override
    public List<ReportValue> getPower(Condition condition, String s) {
        List<ReportValue> list = getPowerDataMapper.getPower(condition, s);
        RegroupData.regroupData(list, true);

        return list;
    }
}
