package com.fs.his.service.impl;

import com.fs.his.dto.DataDTO;
import com.fs.his.dto.inquiryOrderChartDTO;
import com.fs.his.mapper.FsDataMapper;
import com.fs.his.service.IFsDataService;
import com.fs.his.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@SuppressWarnings("all")
@Service
public class IFsDataServiceImpl implements IFsDataService {
    @Autowired
    FsDataMapper fsDataMapper;

    @Override
    public OrderDataVO getOrderData() {
        OrderDataVO o = new OrderDataVO();
        o.setAllOrderNum(fsDataMapper.allOrderNum());
        o.setTodayOrderNum(fsDataMapper.todayOrderNum());
        o.setAllOrderMoney(fsDataMapper.allOrderMoney());
        o.setTodayOrderMoney(fsDataMapper.todayOrderMoney());
        o.setAllInquiryOrderNum(fsDataMapper.allInquiryOrderNum());
        o.setTodayInquiryOrderNum(fsDataMapper.todayInquiryOrderNum());
        o.setTodayDoctor(fsDataMapper.getTodayDoctor());
        o.setTodayMedicinePe(fsDataMapper.getTodayMedicinePe());
        o.setStoreProdNum(fsDataMapper.getStoreProdNum());
        o.setTodayStoreProdNum(fsDataMapper.getTodayStoreProdNum());
        Long doctor = fsDataMapper.getDoctor();
        Long medicinePe = fsDataMapper.getMedicinePe();
        Long patient = fsDataMapper.getPatient();
        o.setUserNum(fsDataMapper.getUserNum());
        o.setTodayUserNum(fsDataMapper.getTodayUserNum());

        o.setDoctor(doctor);
        o.setMedicinePe(medicinePe);
        o.setPatient(patient);
        Long pe = doctor + medicinePe + patient;
        o.setPe(pe);
        return o;
    }

    @Override
    public List<ChartDataVO> getOrderChartData() {
        return fsDataMapper.getOrderChartData();
    }

    @Override
    public List<DoctorChartVO> doctorChartData(Integer type) {
        List<DoctorChartVO> vo=null;
        if (type == 0){
           vo = fsDataMapper.doctorChartData();
        }else
        if (type == 1) {
            vo = fsDataMapper.doctorYearData();
        }else
        if (type == 2) {
            vo = fsDataMapper.doctorMonData();
        }else
        if (type == 3) {
            vo = fsDataMapper.doctorWeekData();
        }else
        if (type == 4) {
            vo = fsDataMapper.doctorDayData();
        }
        return vo;
    }

    @Override
    public List<ChartDataVO> storeOrderChart(DataDTO dto) {
        Integer type=dto.getType();
        Long storeId = dto.getStoreId();
        List<ChartDataVO> vo=null;
        if (type == null){
            vo = fsDataMapper.getOrderChartstoreIdData(storeId);
        }else
        if (type == 1) {
            vo = fsDataMapper.getTodaystoreOrderChart(storeId);
        }else
        if (type == 2) {
            vo = fsDataMapper.getYesterdaystoreOrderChart(storeId);
        }else
        if (type == 3) {
            vo = fsDataMapper.getWeekstoreOrderChart(storeId);
        }else
        if (type == 4) {
            vo = fsDataMapper.getLastWeekstoreOrderChart(storeId);
        }else
        if (type == 5) {
            vo = fsDataMapper.getMonstoreOrderChart(storeId);
        }else
        if (type == 6) {
            vo = fsDataMapper.getLastMonstoreOrderChart(storeId);
            vo.remove(vo.size()-1);
        }else
        if (type == 7) {
            vo = fsDataMapper.getquarterstoreOrderChart(storeId);
        }else
        if (type == 8) {
            vo = fsDataMapper.getLastquarterstoreOrderChart(storeId);
        }else
        if (type == 9) {
            vo = fsDataMapper.getYearstoreOrderChart(storeId);
        }else
        if (type == 10) {
            vo = fsDataMapper.getLastYearstoreOrderChart(storeId);
        }

        return vo;
    }

    @Override
    public List<ChartDataVO> inquiryOrderChart(inquiryOrderChartDTO dto) {
        Integer type=dto.getType();
        Long doctorId = dto.getDoctorId();
        List<ChartDataVO> vo=null;
        if (type == null){
            vo = fsDataMapper.getYearinquiryOrderChart(doctorId);
        }else
        if (type == 1) {
            vo = fsDataMapper.getTodayinquiryOrderChart(doctorId);
        }else
        if (type == 2) {
            vo = fsDataMapper.getYesterdayinquiryOrderChart(doctorId);
        }else
        if (type == 3) {
            vo = fsDataMapper.getWeekinquiryOrderChart(doctorId);
        }else
        if (type == 4) {
            vo = fsDataMapper.getLastWeekinquiryOrderChart(doctorId);
        }else
        if (type == 5) {
            vo = fsDataMapper.getMoninquiryOrderChart(doctorId);
        }else
        if (type == 6) {
            vo = fsDataMapper.getLastMoninquiryOrderChart(doctorId);
            vo.remove(vo.size()-1);
        }else
        if (type == 7) {
            vo = fsDataMapper.getquarterinquiryOrderChart(doctorId);
        }else
        if (type == 8) {
            vo = fsDataMapper.getLastquarterinquiryOrderChart(doctorId);
        }else
        if (type == 9) {
            vo = fsDataMapper.getYearinquiryOrderChart(doctorId);
        }else
        if (type == 10) {
            vo = fsDataMapper.getLastYearinquiryOrderChart(doctorId);
        }

        return vo;
    }

    @Override
    public List<ChartDaVO> storeOrderChartStore(DataDTO dto) {
        return fsDataMapper.getStoreDate(dto);
    }

    @Override
    public List<ChartDaVO> inquiryOrderChartInq(inquiryOrderChartDTO dto) {
        return fsDataMapper.getInquiryOrderChartInq(dto);
    }

    @Override
    public List<ChartProdVO> ChartProdVO(DataDTO dto) {
        List<ChartProdVO> chartProdVos = fsDataMapper.ChartProdVO(dto);
        for (ChartProdVO chartProdVo : chartProdVos) {
            if (chartProdVo.getPrice()!=null){
                chartProdVo.setAllPrice(chartProdVo.getPrice().multiply( chartProdVo.getNum()));
            }

        }
        return chartProdVos;
    }

    @Override
    public StoreOrderDataVO getStoreOrderData(Long id) {
        StoreOrderDataVO Vo = new StoreOrderDataVO();
        Vo.setStore(fsDataMapper.getStore(id));
        Vo.setAStore(fsDataMapper.getAStore(id));
        Vo.setOrder(fsDataMapper.getOrder(id));
        Vo.setYsStore(fsDataMapper.getYsStore(id));
        Vo.setSendStore(fsDataMapper.getSendStore(id));
        Vo.setGetStore(fsDataMapper.getGetStore(id));


        return Vo;
    }

    @Override
    public List<ChartDataVO> getStoreOrderChartData(Long loginUserStoreID) {
        return fsDataMapper.getStoreOrderChartData(loginUserStoreID);
    }

    @Override
    public List<DoctorChartVO> storeChartData(Integer type, Long storeId) {

        return  fsDataMapper.ChartStoreProdVo(type,storeId);
    }

    @Override
    public List<ChartDataVO> getInquiryOrderChartData() {
        return fsDataMapper.getInquiryOrderChartData();
    }

    @Override
    public List<ChartDataVO> getDoctorInquiryOrderChartData(Long doctorId) {
        return fsDataMapper.getDoctorInquiryOrderChartData(doctorId);
    }

    @Override
    public Long todayInquiryCount(Long doctorId) {
        return fsDataMapper.getDoctorInquiryCount(doctorId);
    }
}
