package com.ruoyi.ibs.grid.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ibs.grid.domain.entity.GridCmpmCountLingshou;
import com.ruoyi.ibs.grid.domain.entity.GridVirtualCountGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridVirtualCustGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridVirtualCustLingshou;
import com.ruoyi.ibs.grid.service.IGridVirtualCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ibs.grid.domain.entity.GridVirtualCountLingshou;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虚拟网格汇总统计_零售Controller
 * 
 * @author ruoyi
 * @date 2025-04-24
 */
@Api(tags = "虚拟网格业绩汇总")
@RestController
@RequestMapping("/ibs/gridVirtualCount")
public class GridVirtualCountController extends BaseController
{
    @Autowired
    private IGridVirtualCountService gridVirtualCountService;

    /**
     * 查询虚拟网格汇总统计_零售列表
     */
    @ApiOperation(value = "查询虚拟网格汇总统计_零售列表", notes = "查询虚拟网格汇总统计_零售列表")
    @Log(title = "虚拟网格汇总统计-零售")
    @GetMapping("/lsList")
    public TableDataInfo lslist(String gridName ,String gridType,String dt)
    {
        startPage();
        List<GridVirtualCountLingshou> list = gridVirtualCountService.selectGridVirtualCountLingshouList(gridName, gridType,dt);
        return getDataTable(list);
    }

    @ApiOperation(value = "查询gs汇总", notes = "查询gs汇总")
    @Log(title = "虚拟网格汇总统计-查询gs汇总")
    @GetMapping("/gsList")
    public TableDataInfo gslist(String gridName ,String gridType,String dt)
    {
        startPage();
        List<GridVirtualCountGongsi> list = gridVirtualCountService.selectGridVirtualCountGongsiList(gridName, gridType,dt);
        return getDataTable(list);
    }


    /**
     * 查询虚拟网格明细_零售列表
     */
    @ApiOperation(value = "查询虚拟网格明细_零售列表", notes = "查询虚拟网格明细_零售列表")
    @Log(title = "虚拟网格汇总统计-零售")
    @GetMapping("/lsCustList")
    public TableDataInfo lsCustList(String gridId ,String custName, String custIdc,String dt)
    {
        startPage();
        List<GridVirtualCustLingshou> list = gridVirtualCountService.selectGridVirtualCountlsCustList(gridId, custName, custIdc,dt);
        return getDataTable(list);
    }

    /**
     * 查询虚拟网格明细_公司列表
     */
    @ApiOperation(value = "查询虚拟网格明细_公司列表", notes = "查询虚拟网格明细_公司列表")
    @Log(title = "虚拟网格汇总统计-公司")
    @GetMapping("/gsCustList")
    public TableDataInfo gsCustList(String gridId ,String custName, String custIdc,String dt)
    {
        startPage();
        List<GridVirtualCustGongsi> list = gridVirtualCountService.selectGridVirtualCountgsCustList(gridId, custName, custIdc,dt);
        return getDataTable(list);
    }


    @ApiOperation(value = "导出零售汇总网格", notes = "导出零售汇总网格")
    @Log(title = "虚拟网格汇总统计-导出零售汇总网格")
    @PostMapping("/lsExport")
    public void exportLs(HttpServletResponse response, String gridName ,String gridType,String dt) {
        try {
            ExcelUtil<GridVirtualCountLingshou> util = new ExcelUtil<>(GridVirtualCountLingshou.class);
            util.exportExcel(response, gridVirtualCountService.selectGridVirtualCountLingshouList(gridName, gridType,dt), "零售网格汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "导出公司汇总网格", notes = "导出公司汇总网格")
    @Log(title = "虚拟网格汇总统计-导出公司汇总网格")
    @PostMapping("/gsExport")
    public void exportGs(HttpServletResponse response, String gridName ,String gridType,String dt) {
        try {
            ExcelUtil<GridVirtualCountGongsi> util = new ExcelUtil<>(GridVirtualCountGongsi.class);
            util.exportExcel(response, gridVirtualCountService.selectGridVirtualCountGongsiList(gridName, gridType,dt), "公司网格汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @ApiOperation(value = "导出零售网格明细数据", notes = "导出零售网格明细数据")
    @Log(title = "虚拟网格汇总统计-导出零售网格明细数据")
    @PostMapping("/lsmxExport")
    public void exportLsmx(HttpServletResponse response, String gridId ,String custName, String custIdc,String dt) {
        try {
            ExcelUtil<GridVirtualCustLingshou> util = new ExcelUtil<>(GridVirtualCustLingshou.class);
            util.exportExcel(response, gridVirtualCountService.selectGridVirtualCountlsCustList(gridId, custName, custIdc,dt), "零售网格客户明细汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "导出公司网格明细数据", notes = "导出公司网格明细数据")
    @Log(title = "虚拟网格汇总统计-导出公司网格明细数据")
    @PostMapping("/gsmxExport")
    public void exportGsmx(HttpServletResponse response, String gridId ,String custName, String custIdc,String dt) {
        try {
            ExcelUtil<GridVirtualCustGongsi> util = new ExcelUtil<>(GridVirtualCustGongsi.class);
            util.exportExcel(response, gridVirtualCountService.selectGridVirtualCountgsCustList(gridId, custName, custIdc,dt), "公司网格客户明细汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取虚拟网格汇总统计_零售详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:965:query')")
    @GetMapping(value = "/{dt}")
    public AjaxResult getInfo(@PathVariable("dt") String dt)
    {
        return success(gridVirtualCountService.selectGridVirtualCountLingshouByDt(dt));
    }

    /**
     * 新增虚拟网格汇总统计_零售
     */
    @PreAuthorize("@ss.hasPermi('system:965:add')")
    @Log(title = "虚拟网格汇总统计-零售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GridVirtualCountLingshou GridVirtualCountLingshou)
    {
        return toAjax(gridVirtualCountService.insertGridVirtualCountLingshou(GridVirtualCountLingshou));
    }

    /**
     * 修改虚拟网格汇总统计_零售
     */
    @PreAuthorize("@ss.hasPermi('system:965:edit')")
    @Log(title = "虚拟网格汇总统计-零售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GridVirtualCountLingshou GridVirtualCountLingshou)
    {
        return toAjax(gridVirtualCountService.updateGridVirtualCountLingshou(GridVirtualCountLingshou));
    }

    /**
     * 删除虚拟网格汇总统计_零售
     */
    @PreAuthorize("@ss.hasPermi('system:965:remove')")
    @Log(title = "虚拟网格汇总统计-零售", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dts}")
    public AjaxResult remove(@PathVariable String[] dts)
    {
        return toAjax(gridVirtualCountService.deleteGridVirtualCountLingshouByDts(dts));
    }
}
