package cn.cecep.talroad.controller;

import cn.cecep.talroad.common.core.utils.poi.ExcelUtil;
import cn.cecep.talroad.common.core.utils.poi.ExcelUtilNew;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.domain.BStatTableQueryInfo;
import cn.cecep.talroad.service.BStatTablePwxkWaterAndOtherService;
import cn.cecep.talroad.vo.*;
import cn.cecep.talroad.vo.query.BStatTablepPwxkWaterQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@Api(value = "排污许可执行分析废水固废和其他",tags = "排污许可停机分析废水固废和其他")
@RequestMapping("pwxkTable")
public class BStatTablePwxkWaterAndOtherController {

    @Autowired
    private BStatTablePwxkWaterAndOtherService service;

    @ApiOperation(value = "查询水处理行业生产线信息")
    @PostMapping("/selectProductLine")
    public AjaxResults<IPage<BStatTablePwxkWaterTreatmentLineVo>> selectProductLine(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectProductLine(query);
    }

    @ApiOperation(value = "查询生活污水进水信息")
    @PostMapping("/selectLifeIn")
    public AjaxResults<IPage<BStatTablePwxkWaterLifeInVo>> selectLifeIn(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectLifeIn(query);
    }

    @ApiOperation(value = "查询工业污水进水信息")
    @PostMapping("/selectIndustryIn")
    public AjaxResults<IPage<BStatTablePwxkWaterIndustryInVo>> selectIndustryIn(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectIndustryIn(query);
    }
    @ApiOperation(value = "查询污水处理厂进水监测要求信息")
    @PostMapping("/selectTreatmentInAsk")
    public AjaxResults<IPage<BStatTablePwxkWaterTreatmentInAskVo>> selectTreatmentInAsk(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectTreatmentInAsk(query);
    }
    @ApiOperation(value = "查询工业进水合计信息")
    @PostMapping("/selectIndustryInTotal")
    public AjaxResults<IPage<BStatTablePwxkWaterIndustryInTotalVo>> selectIndustryInTotal(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectIndustryInTotal(query);
    }
    @ApiOperation(value = "查询固废基础信息")
    @PostMapping("/selectHazardousSolidWaste")
    public AjaxResults<IPage<BMainHazardousSolidWasteVo>> selectHazardousSolidWaste(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectHazardousSolidWaste(query);
    }
    @ApiOperation(value = "查询固废自行贮存和处置利用信息")
    @PostMapping("/selectHazardousSolidWasteFa")
    public AjaxResults<IPage<BMainHazardousSolidWasteFaVo>> selectHazardousSolidWasteFa(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectHazardousSolidWasteFa(query);
    }
    @ApiOperation(value = "查询生产设施信息")
    @PostMapping("/selectProductionFacilities")
    public AjaxResults<IPage<BStatTablePwxkProductionFacilitiesVo>> selectProductionFacilities(@RequestBody BStatTablepPwxkWaterQuery query) {
        return  service.selectProductionFacilities(query);
    }
    @ApiOperation(value = "查询产品信息")
    @PostMapping("/selectProducts")
    public AjaxResults<IPage<BStatTablePwxkProductsVo>> selectProducts(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectProducts(query);
    }
    @ApiOperation(value = "查询执行守法报告要求")
    @PostMapping("/selectEnforceComplianceReportingRequirements")
    public AjaxResults<IPage<BMainPollDisEnforcementVo>> selectEnforceComplianceReportingRequirements(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectEnforceComplianceReportingRequirements(query);
    }
    @ApiOperation(value = "查询信息公开要求")
    @PostMapping("/selectPollDisInformation")
    public AjaxResults<IPage<BMainPollDisInformationVo>> selectPollDisInformation(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectPollDisInformation(query);
    }
    @ApiOperation(value = "查询环境管理台账记录要求")
    @PostMapping("/selectPollDisEmlRecord")
    public AjaxResults<IPage<BMainPollDisEmlRecordVo>> selectBMainPollDisEmlRecord(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectBMainPollDisEmlRecord(query);
    }
    @ApiOperation(value = "查询改正规定")
    @PostMapping("/selectPollDisNoiseRegulation")
    public AjaxResults<IPage<BMainPollDisNoiseRegulationVo>> selectBMainPollDisNoiseRegulation(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectBMainPollDisNoiseRegulation(query);
    }
    @ApiOperation(value = "查询原辅料")
    @PostMapping("/selectMaterial")
    public AjaxResults<IPage<BStatTablePwxkRawMaterialVo>> selectMaterial(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectMaterial(query);
    }
    @ApiOperation(value = "查询燃料")
    @PostMapping("/selectFuel")
    public AjaxResults<IPage<BStatTablePwxkFuelVo>> selectFuel(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectFuel(query);
    }
    @ApiOperation(value = "查询锅炉行业气体燃料信息")
    @PostMapping("/selectBoilerFuelGas")
    public AjaxResults<IPage<BStatTablePwxkBoilerFuelGasVo>> selectBoilerFuelGas(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectBoilerFuelGas(query);
    }
    @ApiOperation(value = "查询锅炉行业固体液体燃料信息")
    @PostMapping("/selectBoilerFuelSolidLiquid")
    public AjaxResults<IPage<BStatTablePwxkBoilerFuelSolidLiquidVo>> selectBoilerFuelSolidLiquid(@RequestBody BStatTablepPwxkWaterQuery query) {
        return service.selectBoilerFuelSolidLiquid(query);
    }

    @ApiOperation("保存查询条件")
    @PostMapping("/saveQueryContent")
    public AjaxResults<Integer> saveQueryContent(@RequestBody BStatTableQueryInfo query) {
        return service.saveQueryContent(query);
    }


    @ApiOperation(value = "导出水处理行业生产线信息")
    @PostMapping("/exportProductLine")
    public void exportProductLine(@RequestBody BStatTablepPwxkWaterQuery query, HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkWaterTreatmentLineVo>> iPageAjaxResults = service.selectProductLine(query);
        ExcelUtil<BStatTablePwxkWaterTreatmentLineVo> excelUtil = new ExcelUtil<>(BStatTablePwxkWaterTreatmentLineVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出水处理行业生产线信息");
    }

    @ApiOperation(value = "导出生活污水进水信息")
    @PostMapping("/exportLifeIn")
    public void exportLifeIn(@RequestBody BStatTablepPwxkWaterQuery query
            , HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkWaterLifeInVo>> iPageAjaxResults = service.selectLifeIn(query);
        ExcelUtil<BStatTablePwxkWaterLifeInVo> excelUtil = new ExcelUtil<>(BStatTablePwxkWaterLifeInVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出生活污水进水信息");
    }

    @ApiOperation(value = "导出工业污水进水信息")
    @PostMapping("/exportIndustryIn")
    public void exportIndustryIn(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkWaterIndustryInVo>> iPageAjaxResults = service.selectIndustryIn(query);
        ExcelUtil<BStatTablePwxkWaterIndustryInVo> excelUtil = new ExcelUtil<>(BStatTablePwxkWaterIndustryInVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出工业污水进水信息");
    }
    @ApiOperation(value = "导出污水处理厂进水监测要求信息")
    @PostMapping("/exportTreatmentInAsk")
    public void exportTreatmentInAsk(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                        HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkWaterTreatmentInAskVo>> iPageAjaxResults = service.selectTreatmentInAsk(query);
        ExcelUtil<BStatTablePwxkWaterTreatmentInAskVo> excelUtil = new ExcelUtil<>(BStatTablePwxkWaterTreatmentInAskVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出污水处理厂进水监测要求信息");
    }
    @ApiOperation(value = "导出工业进水合计信息")
    @PostMapping("/exportIndustryInTotal")
    public void exportIndustryInTotal(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                          HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkWaterIndustryInTotalVo>> iPageAjaxResults = service.selectIndustryInTotal(query);
        ExcelUtil<BStatTablePwxkWaterIndustryInTotalVo> excelUtil = new ExcelUtil<>(BStatTablePwxkWaterIndustryInTotalVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出污水处理厂进水监测要求信息");
    }
    @ApiOperation(value = "导出固废基础信息")
    @PostMapping("/exportHazardousSolidWaste")
    public void exportHazardousSolidWaste(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                    HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BMainHazardousSolidWasteVo>> iPageAjaxResults = service.selectHazardousSolidWaste(query);
        ExcelUtil<BMainHazardousSolidWasteVo> excelUtil = new ExcelUtil<>(BMainHazardousSolidWasteVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出污水处理厂进水监测要求信息");
    }
    @ApiOperation(value = "导出固废自行贮存和处置利用信息")
    @PostMapping("/exportHazardousSolidWasteFa")
    public void exportHazardousSolidWasteFa(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                        HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BMainHazardousSolidWasteFaVo>> iPageAjaxResults = service.selectHazardousSolidWasteFa(query);
        System.out.println(iPageAjaxResults.getData().getRecords());
        ExcelUtilNew<BMainHazardousSolidWasteFaVo> excelUtil = new ExcelUtilNew<>(BMainHazardousSolidWasteFaVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出固废自行贮存和处置利用信息");
    }
    @ApiOperation(value = "导出生产设施信息")
    @PostMapping("/exportProductionFacilities")
    public void exportProductionFacilities(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                       HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkProductionFacilitiesVo>> iPageAjaxResults = service.selectProductionFacilities(query);
//        ExcelUtilNew<BStatTablePwxkProductionFacilitiesVo> excelUtil = new ExcelUtilNew<>(BStatTablePwxkProductionFacilitiesVo.class);
//        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出生产设施信息");
        Map<String, Object> exportMap = ExcelUtil.getExportMap(iPageAjaxResults.getData().getRecords(), BStatTablePwxkProductionFacilitiesVo.class);
        ExcelUtil.export(exportMap,"导出生产设施信息");
    }
    @ApiOperation(value = "导出产品信息")
    @PostMapping("/exportProducts")
    public void exportProducts(@RequestBody BStatTablepPwxkWaterQuery query, HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BStatTablePwxkProductsVo>> iPageAjaxResults = service.selectProducts(query);
        ExcelUtil<BStatTablePwxkProductsVo> excelUtil = new ExcelUtil<>(BStatTablePwxkProductsVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出产品信息");
    }
    @ApiOperation(value = "导出执行守法报告要求")
    @PostMapping("/exportReportingRequirements")
    public void exportEnforceComplianceReportingRequirements(
            @RequestBody BStatTablepPwxkWaterQuery query,
            HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        query.setExportOperate(true);
        AjaxResults<IPage<BMainPollDisEnforcementVo>> iPageAjaxResults = service.selectEnforceComplianceReportingRequirements(query);
        ExcelUtil<BMainPollDisEnforcementVo> excelUtil = new ExcelUtil<>(BMainPollDisEnforcementVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出执行守法报告要求");
    }
    @ApiOperation(value = "导出信息公开要求")
    @PostMapping("/exportPollDisInformation")
    public void exportPollDisInformation(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                  HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BMainPollDisInformationVo>> iPageAjaxResults = service.selectPollDisInformation(query);
        ExcelUtil<BMainPollDisInformationVo> excelUtil = new ExcelUtil<>(BMainPollDisInformationVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出信息公开要求");
    }
    @ApiOperation(value = "导出环境管理台账记录要求")
    @PostMapping("/exportPollDisEmlRecord")
    public void exportBMainPollDisEmlRecord(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                   HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        AjaxResults<IPage<BMainPollDisEmlRecordVo>> iPageAjaxResults = service.selectBMainPollDisEmlRecord(query);
        ExcelUtil<BMainPollDisEmlRecordVo> excelUtil = new ExcelUtil<>(BMainPollDisEmlRecordVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出环境管理台账记录要求");
    }
    @ApiOperation(value = "导出改正规定")
    @PostMapping("/exportPollDisNoiseRegulation")
    public void exportBMainPollDisNoiseRegulation(@RequestBody BStatTablepPwxkWaterQuery query,
                                                                                               HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        query.setExportOperate(true);
        AjaxResults<IPage<BMainPollDisNoiseRegulationVo>> iPageAjaxResults = service.selectBMainPollDisNoiseRegulation(query);
        ExcelUtil<BMainPollDisNoiseRegulationVo> excelUtil = new ExcelUtil<>(BMainPollDisNoiseRegulationVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"导出改正规定");
    }
    @ApiOperation(value = "导出锅炉行业气体燃料信息")
    @PostMapping("/exportBoilerFuelGas")
    public void exportBoilerFuelGas(@RequestBody BStatTablepPwxkWaterQuery query, HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        query.setExportOperate(true);
        AjaxResults<IPage<BStatTablePwxkBoilerFuelGasVo>> iPageAjaxResults = service.selectBoilerFuelGas(query);
        ExcelUtil<BStatTablePwxkBoilerFuelGasVo> excelUtil = new ExcelUtil<>(BStatTablePwxkBoilerFuelGasVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"锅炉行业气体燃料信息");
    }
    @ApiOperation(value = "导出锅炉行业固体液体燃料信息")
    @PostMapping("/exportBoilerFuelSolidLiquid")
    public void exportBoilerFuelSolidLiquid(@RequestBody BStatTablepPwxkWaterQuery query, HttpServletResponse response) {
        query.setPageNum(1);
        query.setPageSize(Integer.MAX_VALUE);
        query.setExportOperate(true);
        AjaxResults<IPage<BStatTablePwxkBoilerFuelSolidLiquidVo>> iPageAjaxResults = service.selectBoilerFuelSolidLiquid(query);
        ExcelUtil<BStatTablePwxkBoilerFuelSolidLiquidVo> excelUtil = new ExcelUtil<>(BStatTablePwxkBoilerFuelSolidLiquidVo.class);
        excelUtil.exportExcel(response,iPageAjaxResults.getData().getRecords(),"锅炉行业固体液体燃料信息");
    }
}
