package com.fastbee.data.controller.waterele;

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

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.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.waterele.domain.MaWatereleRecord;
import com.fastbee.waterele.service.IMaWatereleRecordService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 水电双计数据记录Controller
 *
 * @author kerwincui
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/waterele/watereleRecord")
@Api(tags = "水电双计数据记录")
public class MaWatereleRecordController extends BaseController {
    @Autowired
    private IMaWatereleRecordService maWatereleRecordService;

    /**
     * 查询水电双计数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:list')")
    @GetMapping("/list")
    @ApiOperation("查询水电双计数据记录列表")
    public TableDataInfo list(MaWatereleRecord maWatereleRecord) {
//        startPage();
        TableDataInfo tableDataInfo = maWatereleRecordService.selectMaWatereleRecordList(maWatereleRecord);
        return tableDataInfo;
    }

    /**
     * 查询水电双计数据记录echart
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:echart')")
    @GetMapping("/echart")
    @ApiOperation("查询水电双计数据记录echart")
    public Map<String, Object> echart(MaWatereleRecord maWatereleRecord) {
        ArrayList<Object> list  = maWatereleRecordService.chartData(maWatereleRecord);
        return success(list);
    }


    /**
     * 导出水电双计数据记录列表
     */
    @ApiOperation("导出水电双计数据记录列表")
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, MaWatereleRecord maWatereleRecord) {
        TableDataInfo tableDataInfo= maWatereleRecordService.selectMaWatereleRecordList(maWatereleRecord);
        List<MaWatereleRecord> list = (List<MaWatereleRecord>) tableDataInfo.getRows();
        ExcelUtil<MaWatereleRecord> util = new ExcelUtil<MaWatereleRecord>(MaWatereleRecord.class);
        util.exportExcel(response, list, "水电双计数据记录数据");
    }

    /**
     * 获取水电双计数据记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取水电双计数据记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(maWatereleRecordService.selectMaWatereleRecordById(id));
    }

    /**
     * 新增水电双计数据记录
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:add')")
    @PostMapping
    @ApiOperation("新增水电双计数据记录")
    public AjaxResult add(@RequestBody MaWatereleRecord maWatereleRecord) {
        return toAjax(maWatereleRecordService.insertMaWatereleRecord(maWatereleRecord));
    }

    /**
     * 修改水电双计数据记录
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:edit')")
    @PutMapping
    @ApiOperation("修改水电双计数据记录")
    public AjaxResult edit(@RequestBody MaWatereleRecord maWatereleRecord) {
        return toAjax(maWatereleRecordService.updateMaWatereleRecord(maWatereleRecord));
    }

    /**
     * 删除水电双计数据记录
     */
    @PreAuthorize("@ss.hasPermi('waterele:watereleRecord:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除水电双计数据记录")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(maWatereleRecordService.deleteMaWatereleRecordByIds(ids));
    }
}
