package com.jeethink.tjfx.service.impl;


import com.jeethink.tjfx.mapper.TjfxMapper;
import com.jeethink.tjfx.service.ITjfxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 统计分析 服务层
 *
 * @author wms
 */
@Service
public class TjfxServiceImpl implements ITjfxService
{
    @Autowired
    private TjfxMapper tjfxMapper;

    @Override
    public HashMap selectShowData() {
        HashMap map = new HashMap();
        List<HashMap> receive = new ArrayList<>();
        List<HashMap> manage = new ArrayList<>();
        List<HashMap> use = new ArrayList<>();
        List<HashMap> save = new ArrayList<>();
        receive = tjfxMapper.selectReceiveCount();
        manage = tjfxMapper.selectManageCount();
        use = tjfxMapper.selectUseCount();
        save = tjfxMapper.selectSaveCount();
        map.put("receive",receive);
        map.put("manage",manage);
        map.put("use",use);
        map.put("save",save);
        return map;
    }

    @Override
    public List<HashMap> selectReceiveList() {
        List<HashMap> receiveList = tjfxMapper.selectReceiveList();
        return receiveList;
    }

    @Override
    public List<HashMap> selectBorrowList() {
        List<HashMap> borrowList = tjfxMapper.selectBorrowList();
        return borrowList;
    }
    @Override
    public List<HashMap> selectReturnList() {
        List<HashMap> returnList = tjfxMapper.selectReturnList();
        return returnList;
    }
    @Override
    public List<HashMap> selectPieChartList() {
        List<HashMap> pieChartList = tjfxMapper.selectPieChartList();
        return pieChartList;
    }

    @Override
    public List<HashMap> selectRKListByMonth() {
        List<HashMap> RKListByMonth = tjfxMapper.selectRKListByMonth();
        return RKListByMonth;
    }
    @Override
    public List<HashMap> selectJyPieChartList() {
        List<HashMap> jyPieChartList = tjfxMapper.selectJyPieChartList();
        return jyPieChartList;
    }
    @Override
    public List<HashMap> selectTJListByMonth() {
        List<HashMap> jyPieChartList = tjfxMapper.selectTJListByMonth();
        return jyPieChartList;
    }
    @Override
    public List<HashMap> selectTJListByYear() {
        List<HashMap> jyPieChartList = tjfxMapper.selectTJListByYear();
        return jyPieChartList;
    }

    @Override
    public List<HashMap> selectReceiveLineList() {
        List<HashMap> rsList = tjfxMapper.selectRsListByMonth();
        List<HashMap> jkList = tjfxMapper.selectJkListByMonth();
        List list0 = Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        List<HashMap> list = new ArrayList<>();
        HashMap map1 = new HashMap();
        map1.put("name","人事");
        if(rsList.size()>0){
            List list1 = new ArrayList();
            list1.add(rsList.get(0).get("January"));
            list1.add(rsList.get(0).get("February"));
            list1.add(rsList.get(0).get("March"));
            list1.add(rsList.get(0).get("April"));
            list1.add(rsList.get(0).get("May"));
            list1.add(rsList.get(0).get("June"));
            list1.add(rsList.get(0).get("July"));
            list1.add(rsList.get(0).get("August"));
            list1.add(rsList.get(0).get("September"));
            list1.add(rsList.get(0).get("October"));
            list1.add(rsList.get(0).get("November"));
            list1.add(rsList.get(0).get("December"));
            map1.put("data",list1);
        }else{
            map1.put("data",list0);
        }
        list.add(map1);
        HashMap map2 = new HashMap();
        map2.put("name","健康");
        if(jkList.size()>0){
            List list2 = new ArrayList();
            list2.add(jkList.get(0).get("January"));
            list2.add(jkList.get(0).get("February"));
            list2.add(jkList.get(0).get("March"));
            list2.add(jkList.get(0).get("April"));
            list2.add(jkList.get(0).get("May"));
            list2.add(jkList.get(0).get("June"));
            list2.add(jkList.get(0).get("July"));
            list2.add(jkList.get(0).get("August"));
            list2.add(jkList.get(0).get("September"));
            list2.add(jkList.get(0).get("October"));
            list2.add(jkList.get(0).get("November"));
            list2.add(jkList.get(0).get("December"));
            map2.put("data",list2);
        }else{
            map2.put("data",list0);
        }
        list.add(map2);
        return list;
    }
    @Override
    public List<HashMap> selectBorrowBarList() {
        List<HashMap> rsList = tjfxMapper.selectRsJyListByMonth();
        List<HashMap> jkList = tjfxMapper.selectJkJyListByMonth();
        List list0 = Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        List<HashMap> list = new ArrayList<>();
        HashMap map1 = new HashMap();
        map1.put("name","人事");
        if(rsList.size()>0){
            List list1 = new ArrayList();
            list1.add(rsList.get(0).get("January"));
            list1.add(rsList.get(0).get("February"));
            list1.add(rsList.get(0).get("March"));
            list1.add(rsList.get(0).get("April"));
            list1.add(rsList.get(0).get("May"));
            list1.add(rsList.get(0).get("June"));
            list1.add(rsList.get(0).get("July"));
            list1.add(rsList.get(0).get("August"));
            list1.add(rsList.get(0).get("September"));
            list1.add(rsList.get(0).get("October"));
            list1.add(rsList.get(0).get("November"));
            list1.add(rsList.get(0).get("December"));
            map1.put("data",list1);
        }else{
            map1.put("data",list0);
        }
        list.add(map1);
        HashMap map2 = new HashMap();
        map2.put("name","健康");
        if(jkList.size()>0){
            List list2 = new ArrayList();
            list2.add(jkList.get(0).get("January"));
            list2.add(jkList.get(0).get("February"));
            list2.add(jkList.get(0).get("March"));
            list2.add(jkList.get(0).get("April"));
            list2.add(jkList.get(0).get("May"));
            list2.add(jkList.get(0).get("June"));
            list2.add(jkList.get(0).get("July"));
            list2.add(jkList.get(0).get("August"));
            list2.add(jkList.get(0).get("September"));
            list2.add(jkList.get(0).get("October"));
            list2.add(jkList.get(0).get("November"));
            list2.add(jkList.get(0).get("December"));
            map2.put("data",list2);
        }else{
            map2.put("data",list0);
        }
        list.add(map2);
        return list;
    }

}
