package com.yh.saas.plugin.yiliangyiyun.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 记录费用表信息 前端控制器
 * </p>
 *
 * @author Gdc
 * @since 2022-05-29
 */
@RestController
@RequestMapping("/expenseInfo")
public class ExpenseInfoController {
    @Autowired
    private IExpenseInfoService expenseInfoService;

    /**
     * 费用详情列表查询
     *
     * @param expenseInfo
     * @return
     */
    @GetMapping("/selectInfo")
    public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
        return expenseInfoService.selectInfo(expenseInfo);
    }
    /**
     * 查看费用详情信息
     */
    @GetMapping("/ExpenseInfo")
    public ExpenseInfo getInfo(@RequestParam String id) {
        return expenseInfoService.getInfo(id);
    }
    /**
     * 删除
     *
     * @param example
     * @return
     */
    @PostMapping("/deleteInfo")
    public void deleteInfo(@RequestBody ExpenseInfo example) {
        expenseInfoService.deleteInfo(example.getId());
    }
    /**
     * 请款 收款
     */
    @PostMapping("/api/addInfo")
    public String addInfo(@RequestBody @Valid ExpenseInfo expenseInfo) {
        return expenseInfoService.addInfo(expenseInfo);
    }
    /**
     * 编辑
     */
    @PostMapping("/editInfo")
    public String editInfo(@RequestBody ExpenseInfo expenseInfo) {
        return expenseInfoService.editInfo(expenseInfo);
    }
    /**
     * 付款
     */
    @PostMapping("/payment")
    public String payment(@RequestBody ExpenseInfo expenseInfo) {
        return expenseInfoService.payment(expenseInfo);
    }
    /**
     * 删除
     *
     * @param example
     * @return
     */
    @PostMapping("/deleteAllocationInfo")
    public void deleteAllocationInfo(@RequestBody ExpenseInfo example) {
        expenseInfoService.deleteAllocationInfo(example.getId());
    }
    /**
     * 查看入库单下拉列表
     * @param contractNo,warehouseName,receiptDocDate
     * @return
     */
    @GetMapping("/selectWarehousingOrder")
    public List<WarehousingOrder> selectWarehousingOrder(String contractNo, String warehouseName, String receiptDocDate) {
        return expenseInfoService.selectWarehousingOrder(contractNo,warehouseName,receiptDocDate);
    }

    /**
     * 费用管理图表
     *
     * @param compId
     * @return
     */
    @GetMapping("/expenseChart")
    public List<ExpenseInfo> expenseChart(String compId, int year){
        return expenseInfoService.expenseChart(compId,year);
    }
    /**
     * 费用收支一览表
     *
     * @param compId
     * @return
     */
    @GetMapping("/expenseList")
    public List<ExpenseInfo> expenseList(String compId, String startDate, String endDate){
        return expenseInfoService.expenseList(compId,startDate,endDate);
    }
    /**
     * 手机审核文件下载
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/exportPhone")
    public String exportPhone(@RequestBody ExpenseInfo example, HttpServletResponse response) throws Exception {
        return expenseInfoService.exportPhone(example,response);
    }
    /**
     * 查当天提交的费用条数
     */
    @GetMapping("/api/expenseCount")
    public Integer expenseCount(ExpenseInfo expenseInfo){
        return expenseInfoService.expenseCount(expenseInfo);
    }

}

