package com.ruoyi.ibs.grid.controller;


import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ibs.grid.domain.entity.GridCmpmCountGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridCmpmCountLingshou;
import com.ruoyi.ibs.grid.domain.entity.GridCmpmCountLingshou;
import com.ruoyi.ibs.grid.domain.entity.GridCustCountGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridCustCountLingshou;
import com.ruoyi.ibs.grid.service.GridCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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


@Api(tags = "网格汇总")
@RestController
@RequestMapping("/ibs/GridCount/")
public class GridCountController extends BaseController {

    @Autowired
    GridCountService service;

    @Log(title = "查询零售网格汇总列表")
    @ApiOperation(value = "查询零售汇总网格列表")
    @GetMapping("LsList")
    public TableDataPageInfo<GridCmpmCountLingshou> selectLsCountList(String town, String village,String dt) {
        Page<Object> page = startPage();
        List<GridCmpmCountLingshou> list = service.selectLsCountList(town, village,dt);
        return getDataTable(list, page);
    }

    @Log(title = "查询公司网格汇总列表")
    @ApiOperation(value = "查询公司汇总网格列表")
    @GetMapping("GsList")
    public TableDataPageInfo<GridCmpmCountGongsi> selectGsCountList(String town, String village,String dt) {
        Page<Object> page = startPage();
        List<GridCmpmCountGongsi> list = service.selectGsCountList(town, village,dt);
        return getDataTable(list, page);
    }

//    @Log(title = "导出零售汇总网格")
//    @ApiOperation(value = "导出零售汇总网格", produces = "application/octet-stream")
//    @GetMapping("exportLs")
//    public void exportLs(HttpServletResponse response, String town, String village) {
//        try {
//            ExcelUtil<GridCmpmCountLingshou> util = new ExcelUtil<>(GridCmpmCountLingshou.class);
//            util.exportExcel(response, service.selectLsCountList(town, village), "零售网格汇总");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Log(title = "导出公司汇总网格")
//    @ApiOperation(value = "导出公司汇总网格", produces = "application/octet-stream")
//    @GetMapping("exportGs")
//    public void exportGs(HttpServletResponse response, String town, String village) {
//        try {
//            ExcelUtil<GridCmpmCountGongsi> util = new ExcelUtil<>(GridCmpmCountGongsi.class);
//            util.exportExcel(response, service.selectGsCountList(town, village), "公司网格汇总");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }

    @Log(title = "查询零售客户明细")
    @ApiOperation(value = "查询零售客户明细")
    @GetMapping("LsCustList")
    public TableDataPageInfo<GridCustCountLingshou> selectLsCustList(@RequestParam String regionCode, String custName, String custIdc,String dt) {
        Page<Object> page = startPage();
        List<GridCustCountLingshou> list = service.selectLsCustList(regionCode, custName, custIdc,dt);
        return getDataTable(list, page);
    }

    @Log(title = "查询公司客户明细")
    @ApiOperation(value = "查询公司客户明细")
    @GetMapping("GsCustList")
    public TableDataPageInfo<GridCustCountGongsi> selectGsCustList(@RequestParam String regionCode, String custName, String socialCreditCode,String dt) {
        Page<Object> page = startPage();
        List<GridCustCountGongsi> list = service.selectGsCustList(regionCode, custName, socialCreditCode,dt);
        return getDataTable(list, page);
    }



//    @Log(title = "导出零售客户明细")
//    @ApiOperation(value = "导出零售客户明细", produces = "application/octet-stream")
//    @GetMapping("exportLsCust")
//    public void exportLsCust(HttpServletResponse response, @RequestParam String regionCode, String custName, String custIdc) {
//        try {
//            ExcelUtil<GridCustCountLingshou> util = new ExcelUtil<>(GridCustCountLingshou.class);
//            util.exportExcel(response, service.selectLsCustList(regionCode, custName, custIdc), "网格客户明细");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//
//    @Log(title = "导出公司客户明细")
//    @ApiOperation(value = "导出公司客户明细", produces = "application/octet-stream")
//    @GetMapping("exportGsCust")
//    public void exportGsCust(HttpServletResponse response, @RequestParam String regionCode, String custName, String socialCreditCode) {
//        try {
//            ExcelUtil<GridCustCountGongsi> util = new ExcelUtil<>(GridCustCountGongsi.class);
//            util.exportExcel(response, service.selectGsCustList(regionCode, custName, socialCreditCode), "网格客户明细");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
}
