package com.jjt.ws.controller;

import com.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.core.page.TableDataInfo;
import com.jjt.common.enums.BusinessType;
import com.jjt.common.utils.DateUtils;
import com.jjt.elec.domain.ElecPrice;
import com.jjt.ws.domain.TwinWorkshopCalc;
import com.jjt.ws.service.ITwinWorkshopCalcService;
import com.jjt.ws.vo.MonthCalcVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

/**
 * 能源统计Controller
 *
 * @author wukai
 * @date 2025-01-17
 */
@Api(tags = "能源统计")
@RestController
@RequestMapping("/ws/calc")
public class TwinWorkshopCalcController extends BaseController {
    @Resource
    private ITwinWorkshopCalcService twinWorkshopCalcService;

    /**
     * 查询能源统计列表
     */
    @ApiOperation("查询能源统计列表")
    @PreAuthorize("@ss.hasPermi('ws:calc:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinWorkshopCalc twinWorkshopCalc) {
        startPage();
        List<TwinWorkshopCalc> list = twinWorkshopCalcService.selectTwinWorkshopCalcList(twinWorkshopCalc);
        return getDataTable(list);
    }

    /**
     * 获取能源统计详细信息
     */
    @ApiOperation("获取能源统计详细信息")
    @PreAuthorize("@ss.hasPermi('ws:calc:query')")
    @GetMapping(value = "/{calcId}")
    public AjaxResult getInfo(@PathVariable("calcId") Long calcId) {
        return success(twinWorkshopCalcService.selectTwinWorkshopCalcByCalcId(calcId));
    }

    /**
     * 新增能源统计
     */
    @ApiOperation("新增能源统计")
    @PreAuthorize("@ss.hasPermi('ws:calc:add')")
    @Log(title = "能源统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinWorkshopCalc twinWorkshopCalc) {
        return toAjax(twinWorkshopCalcService.insertTwinWorkshopCalc(twinWorkshopCalc));
    }

    /**
     * 修改能源统计
     */
    @ApiOperation("修改能源统计")
    @PreAuthorize("@ss.hasPermi('ws:calc:edit')")
    @Log(title = "能源统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinWorkshopCalc twinWorkshopCalc) {
        return toAjax(twinWorkshopCalcService.updateTwinWorkshopCalc(twinWorkshopCalc));
    }

    /**
     * 删除能源统计
     */
    @ApiOperation("删除能源统计")
    @PreAuthorize("@ss.hasPermi('ws:calc:remove')")
    @Log(title = "能源统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{calcIds}")
    public AjaxResult remove(@PathVariable Long[] calcIds) {
        return toAjax(twinWorkshopCalcService.deleteTwinWorkshopCalcByCalcIds(calcIds));
    }
}
