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.finance.domain.TWareHouseFees;
import com.ruoyi.finance.service.ITFeeService;
import com.ruoyi.reportManagement.excel.Profit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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/profit")
public class ProfitController extends BaseController {

    @Autowired
    private ITFeeService tFeeService;

    /**
     * 查询应收总账列表
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @GetMapping("/list")
    public TableDataInfo chargeList(TWareHouseFees tWareHouseFees) {
        startPage();
        List<Map<String, Object>> list = tFeeService.warehouseBillsFeesProfitList(tWareHouseFees);
        return getDataTable(list);
    }

    /**
     * 应付总账列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:profit:export')")
    @Log(title = "库存总账", businessType = BusinessType.EXPORT)
    @DataScope(deptAlias = "d", userAlias = "u")
    @GetMapping("/export")
    public AjaxResult export(TWareHouseFees tWareHouseFees) throws Exception {
        List<Profit> list = tFeeService.profitExport(tWareHouseFees);
        ExcelUtil<Profit> util = new ExcelUtil<Profit>(Profit.class);
        return util.exportExcel(list, "利润总账");
    }

}
