package com.dgtly.order.controller;

import java.util.List;

import com.dgtly.order.domain.OrderSalesGroup;
import com.dgtly.order.domain.SalesOrderBase;
import com.dgtly.order.service.ISalesOrderBaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dgtly.common.annotation.Log;
import com.dgtly.common.enums.BusinessType;


import com.dgtly.common.core.controller.BaseController;
import com.dgtly.common.core.domain.AjaxResult;
import com.dgtly.common.utils.poi.ExcelUtil;
import com.dgtly.common.core.page.TableDataInfo;

/**
 * 要货查询 Controller
 * 
 * @author chenyn
 * @date 2023-05-23
 */
@Controller
@RequestMapping("/order/salesOrderBase")
public class SalesOrderBaseController extends BaseController
{
    private String prefix = "order/salesOrderBase";

    @Autowired
    private ISalesOrderBaseService salesOrderBaseService;

    @RequiresPermissions("order:salesOrderBase:view")
    @GetMapping()
    public String orderDemand()
    {
        return prefix + "/orderDemand";
    }
//    public String group()
//    {
//        return prefix + "/groupList";
//    }

    /**
     * 查询【要货查询】 列表
     */
    @RequiresPermissions("order:salesOrderBase:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SalesOrderBase salesOrderBase)
    {
        startPage();
        List<SalesOrderBase> list = salesOrderBaseService.selectSalesOrderBaseList(salesOrderBase);
        return getDataTable(list);
    }

    /**
     * 导出【要货查询】 列表
     */
    @RequiresPermissions("order:salesOrderBase:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SalesOrderBase salesOrderBase)
    {
        List<SalesOrderBase> list = salesOrderBaseService.selectSalesOrderBaseList(salesOrderBase);
        if (list.size() >= 10000) {

            return new AjaxResult(301, "数据大于 10000 条Excel将无法打开，请过滤查询条件");
        }
        ExcelUtil<SalesOrderBase> util = new ExcelUtil<SalesOrderBase>(SalesOrderBase.class);
        return util.exportExcel(list, "要货查询");
    }
//
//    /**
//     * 修改【销售分部目标达成】
//     */
//    @GetMapping("/edit/{id}")
//    public String edit(@PathVariable("id") Long id, ModelMap mmap)
//    {
////        OrderSalesGroup orderSalesGroup = orderSalesGroupService.selectOrderSalesGroupById(id);
////        mmap.put("orderSalesGroup", orderSalesGroup);
//        return prefix + "/edit";
//    }

}
