| | |
| | | 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; |
| | |
| | | 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 javax.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) |
| | |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/addBatch") |
| | | @ApiOperation("用电时段-批量新增") |
| | | @Log(title = "用电时段-批量新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult addBatch(@RequestBody List<EnergyPeriod> energyPeriods) { |
| | | boolean save = energyPeriodService.saveBatch(energyPeriods); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("用电时段-修改") |
| | | @Log(title = "用电时段-修改", businessType = BusinessType.UPDATE) |
| | |
| | | @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("删除失败"); |
| | | } |
| | |
| | | @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(), "用电时段数据"); |
| | | } |
| | | |
| | | } |