package com.ruoyi.web.controller.warehouse.reportManagement;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 出入库汇总Controller
 * 总账统计
 *
 * @author ruoyi
 * @date 2020-12-23
 */
@RestController
@RequestMapping("/warehouseBusiness/summary")
public class TWarehousebillsitemsSummaryController extends BaseController {
    @Autowired
    private ITWarehouseBillsService itWarehouseBillsService;

    /**
     * 查询库存总账列表
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @GetMapping("/list")
    public TableDataInfo list(TWarehouseBills tWarehouseBills) {
        startPage();
        List<Map<String, Object>> list = itWarehouseBillsService.selectInventoryList(tWarehouseBills);
        return getDataTable(list);
    }

    /**
     * 导出库存总账列表
     */
    @Log(title = "出入库统计", businessType = BusinessType.EXPORT)
    @DataScope(deptAlias = "d", userAlias = "u")
    @GetMapping("/export")
    public AjaxResult export(TWarehouseBills tWarehouseBills) {
        List<TWareHouseItemsExcel> list = itWarehouseBillsService.selectTWarehousebillsItemsList(tWarehouseBills);
        ExcelUtil<TWareHouseItemsExcel> util = new ExcelUtil<TWareHouseItemsExcel>(TWareHouseItemsExcel.class);
        return util.statisticsExportExcel(list, "总账统计");
    }

    /**
     * 出入库、库存统计
     */
    @GetMapping("/stockStatistics")
    public AjaxResult stockStatistics() {
        return itWarehouseBillsService.stockStatistics();
    }

    /**
     * 周期库存统计
     */
    @GetMapping("/cycleStockStatistics")
    public AjaxResult cycleStockStatistics() {
        return itWarehouseBillsService.cycleStockStatistics();
    }

}
