package com.lightinit.hsdatashow.impl.topic.water;

import com.lightinit.hsdatashow.mapper.StWaterReservoirMapper;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.model.topic.water.STChartModel;
import com.lightinit.hsdatashow.service.topic.water.IHanQingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @Author: sunxiang
 * @Date: 2018/12/25 9:52
 * @Description:
 **/
@Service
public class HanQingServiceImpl implements IHanQingService {

    @Autowired
    private StWaterReservoirMapper stWaterReservoirMapper;
    @Override
    public ResultState getbenshishangyoubenyuelaishuizongliang() {
        ResultState<Object> resultState = new ResultState<>();
        Object obj=stWaterReservoirMapper.getbenshishangyoubenyuelaishuizongliang();
        resultState.setData(obj);
        return resultState;
    }

    @Override
    public ResultState getquanshixiayueyujilaishuizongliang() {
        ResultState<Object> resultState = new ResultState<>();
        Object obj=stWaterReservoirMapper.getquanshixiayueyujilaishuizongliang();
        resultState.setData(obj);
        return resultState;
    }

    @Override
    public ResultState getquanshixiayueyucekeyongzongshuiliang() {
        ResultState<Object> resultState = new ResultState<>();
        Object obj=stWaterReservoirMapper.getquanshixiayueyucekeyongzongshuiliang();
        resultState.setData(obj);
        return resultState;
    }

    @Override
    public ResultState getlianxuganhantu() {
        ResultState<Object> resultState = new ResultState<>();
        HashMap<String, Object> map = new HashMap<>();
        List<STChartModel> lists=stWaterReservoirMapper.getlianxuganhantu();
        ArrayList<Object> names = new ArrayList<>();
        if(lists==null||lists.size()<0){
            map.put("names",null);
            map.put("list",null);
            resultState.setData(map);
            return resultState;
        }
        for (STChartModel stChartModel : lists) {
            names.add(stChartModel.getName());
        }
        map.put("names",names);
        map.put("list",lists);
        resultState.setData(map);
        return resultState;
    }
}
