liding
2026-04-23 1b3d13f691957d4fffdfb3671dc09f66b6e3dfd0
src/main/java/com/ruoyi/equipmentenergyconsumption/controller/EnergyPeriodController.java
@@ -3,7 +3,6 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.equipmentenergyconsumption.pojo.ElectricityConsumptionArea;
import com.ruoyi.equipmentenergyconsumption.pojo.EnergyPeriod;
import com.ruoyi.equipmentenergyconsumption.service.EnergyPeriodService;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
@@ -12,19 +11,20 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping("/energyPeriod")
@Api(tags = "用电时段")
@AllArgsConstructor
public class EnergyPeriodController extends BaseController {
    @Autowired
    private EnergyPeriodService energyPeriodService;
    private final EnergyPeriodService energyPeriodService;
    @GetMapping("/listPage")
    @ApiOperation("用电时段-分页查询")
    @Log(title = "用电时段-分页查询", businessType = BusinessType.OTHER)
@@ -61,7 +61,7 @@
    @ApiOperation("用电时段-删除")
    @Log(title = "用电时段-删除", businessType = BusinessType.DELETE)
    public AjaxResult delete(@RequestBody List<Long> ids) {
        if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("请选择至少一条数据");
        if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("请选择至少一条数据");
        boolean remove = energyPeriodService.removeBatchByIds(ids);
        return remove ? AjaxResult.success() : AjaxResult.error("删除失败");
    }
@@ -74,11 +74,11 @@
    @PostMapping("/export")
    @ApiOperation("导出用电时段")
    public void export(HttpServletResponse response) {
        Page page = new Page(-1,-1);
        Page page = new Page(-1, -1);
        EnergyPeriod energyPeriod = new EnergyPeriod();
        IPage<EnergyPeriod> listPage = energyPeriodService.listPage(page, energyPeriod);
        ExcelUtil<EnergyPeriod> util = new ExcelUtil<EnergyPeriod>(EnergyPeriod.class);
        util.exportExcel(response, listPage.getRecords() , "用电时段数据");
        util.exportExcel(response, listPage.getRecords(), "用电时段数据");
    }
}