package com.fs.hisStore.controller.store;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.dto.DataDTO;
import com.fs.his.vo.*;
import com.fs.hisStore.service.IFsDataScrmService;
import com.fs.hisStore.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/store/store/data")
public class DataScrmController extends BaseController {
    @Autowired
    IFsDataScrmService iFsDataService;

    @GetMapping("/orderData")
    public AjaxResult list() {

        StoreOrderDataVO list = iFsDataService.getStoreOrderData(UserUtil.getLoginUserStoreID());
        return AjaxResult.success(list);
    }

    @GetMapping("/orderChartData")
    public AjaxResult orderChartList() {
        List<ChartDataVO> list = iFsDataService.getStoreOrderChartData(UserUtil.getLoginUserStoreID());
        return AjaxResult.success(list);
    }
    @GetMapping("/storeChartData/{type}")
    public AjaxResult storeChartData(@PathVariable("type")Integer type) {
        List<DoctorChartVO> list = iFsDataService.storeChartData(type, UserUtil.getLoginUserStoreID());
        return AjaxResult.success(list);
    }


    @GetMapping("/storeOrderChart")
    public AjaxResult storeOrderChart( DataDTO dto) {
        dto.setStoreId(UserUtil.getLoginUserStoreID());
        List<ChartDataVO> list = iFsDataService.storeOrderChart(dto);
        return AjaxResult.success(list);
    }

    @GetMapping("/storeOrderChartStore")
    public AjaxResult storeOrderChartStore( DataDTO dto) {
        dto.setStoreId(UserUtil.getLoginUserStoreID());
        List<ChartDaVO> list = iFsDataService.storeOrderChartStore(dto);
        return AjaxResult.success(list);
    }

    @GetMapping("/storeProd")
    public AjaxResult storeProd( DataDTO dto) {
        dto.setStoreId(UserUtil.getLoginUserStoreID());
        List<ChartProdVO> list = iFsDataService.ChartProdVO(dto);
        return AjaxResult.success(list);
    }

    @Log(title = "药品订单统计", businessType = BusinessType.EXPORT)
    @GetMapping("/storeExport")
    public AjaxResult storeExport( DataDTO dto)
    {
        dto.setStoreId(UserUtil.getLoginUserStoreID());
        List<ChartDaVO> list = iFsDataService.storeOrderChartStore(dto);
        ExcelUtil<ChartDaVO> util = new ExcelUtil<ChartDaVO>(ChartDaVO.class);
        return util.exportExcel(list, "药品订单统计");
    }

    @Log(title = "药品销量订单统计", businessType = BusinessType.EXPORT)
    @GetMapping("/storeProdExport")
    public AjaxResult storeProdExport( DataDTO dto)
    {
        dto.setStoreId(UserUtil.getLoginUserStoreID());
        List<ChartProdVO> list = iFsDataService.ChartProdVO(dto);
        ExcelUtil<ChartProdVO> util = new ExcelUtil<ChartProdVO>(ChartProdVO.class);
        return util.exportExcel(list, "药品订单统计");
    }
}
